#include <bits/stdc++.h>
int samea[30], sameb[30];
int a[30], b[30];
bool check(int A, int B) {
  int ya = 0;
  int yb = 0;
  for (int i = 1; i <= A; i++) {
    if (samea[i] != a[i]) ya++;
  }
  for (int i = 1; i <= B; i++) {
    if (sameb[i] != b[i]) yb++;
  }
  if (ya == 0 && yb == 0)
    return true;
  else
    return false;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int k1, k2;
    scanf("%d", &k1);
    for (int i = 1; i <= k1; i++) {
      scanf("%d", &a[i]);
      samea[i] = a[i];
    }
    scanf("%d", &k2);
    for (int i = 1; i <= k2; i++) {
      scanf("%d", &b[i]);
      sameb[i] = b[i];
    }
    int lena = k1, lenb = k2;
    int number = 0;
    int flag = 0;
    while (lena != 0 && lenb != 0) {
      if (a[1] < b[1]) {
        for (int i = 1; i <= lenb; i++) {
          b[i - 1] = b[i];
        }
        b[lenb] = a[1];
        lenb++;
        b[lenb] = b[0];
        for (int j = 1; j <= lena; j++) {
          a[j - 1] = a[j];
        }
        lena = lena - 1;
        number++;
      } else if (b[1] < a[1]) {
        for (int i = 1; i <= lena; i++) {
          a[i - 1] = a[i];
        }
        a[lena] = b[1];
        lena++;
        a[lena] = a[0];
        for (int j = 1; j <= lenb; j++) {
          b[j - 1] = b[j];
        }
        lenb = lenb - 1;
        number++;
      }
      if (number >= 1000) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      printf("-1\n");
    } else if (lena == 0) {
      printf("%d %d\n", number, 2);
    } else {
      printf("%d %d\n", number, 1);
    }
  }
  return 0;
}
