#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int na, nb, x;
  queue<int> a, b;
  scanf("%d", &na);
  for (int i = 0; i < na; ++i) {
    scanf("%d", &x);
    a.push(x);
  }
  scanf("%d", &nb);
  for (int i = 0; i < nb; ++i) {
    scanf("%d", &x);
    b.push(x);
  }
  int sum = 0;
  while (!a.empty() && !b.empty()) {
    if (sum <= 1000) {
      int af = a.front();
      a.pop();
      int bf = b.front();
      b.pop();
      if (af > bf) {
        a.push(bf);
        a.push(af);
        sum++;
      } else {
        b.push(af);
        b.push(bf);
        sum++;
      }
    } else
      break;
  }
  if (a.empty())
    printf("%d 2\n", sum);
  else if (b.empty())
    printf("%d 1\n", sum);
  else
    printf("-1\n");
  return 0;
}
