#include <bits/stdc++.h>
using namespace std;
queue<int> s1;
queue<int> s2;
int main() {
  int n, n1, n2, i, x;
  scanf("%d", &n);
  scanf("%d", &n1);
  for (i = 0; i < n1; i++) {
    scanf("%d", &x);
    s1.push(x);
  }
  scanf("%d", &n2);
  for (i = 0; i < n2; i++) {
    scanf("%d", &x);
    s2.push(x);
  }
  int flag = 0, k = 0;
  while (!flag && k < 1000) {
    k++;
    if (s1.front() > s2.front()) {
      s1.push(s2.front());
      s1.push(s1.front());
      s1.pop();
      s2.pop();
      n1++;
      n2--;
    } else {
      s2.push(s1.front());
      s2.push(s2.front());
      s1.pop();
      s2.pop();
      n2++;
      n1--;
    }
    if (n1 == 0) flag = 2;
    if (n2 == 0) flag = 1;
  }
  if (k >= 1000)
    printf("-1\n");
  else
    printf("%d %d\n", k, flag);
  return 0;
}
