#include <bits/stdc++.h>
using namespace std;
struct node {
  char a;
  long long b;
} stu[2000];
int a[200000];
set<int> c;
queue<int> d, e;
int main() {
  int n, m, i, j, k, p, q, k1, k2, x, y, num = 0, l;
  int a[10], b[10];
  scanf("%d", &n);
  scanf("%d", &k1);
  for (i = 0; i < k1; i++) {
    scanf("%d", &a[i]);
    d.push(a[i]);
  }
  scanf("%d", &k2);
  for (i = 0; i < k2; i++) {
    scanf("%d", &b[i]);
    e.push(b[i]);
  }
  while (d.size() != 0 && e.size() != 0) {
    if (num == 10000) {
      printf("-1\n");
      return 0;
    }
    if (d.front() > e.front()) {
      x = d.front();
      y = e.front();
      d.pop();
      e.pop();
      d.push(y);
      d.push(x);
      num++;
      continue;
    }
    if (d.front() < e.front()) {
      x = d.front();
      y = e.front();
      d.pop();
      e.pop();
      e.push(x);
      e.push(y);
      num++;
      continue;
    }
  }
  if (d.size() == 0)
    l = 2;
  else
    l = 1;
  printf("%d %d\n", num, l);
  return 0;
}
