#include <bits/stdc++.h>
using namespace std;
map<string, bool> m[11][11];
void input() {
  int i, n1, n2, n;
  int a[20], b[20], val[20];
  scanf("%d", &n);
  scanf("%d", &n1);
  for ((i) = 0; (i) < (n1); (i)++) scanf("%d", &a[i]);
  scanf("%d", &n2);
  for ((i) = 0; (i) < (n2); (i)++) scanf("%d", &b[i]);
  for ((i) = 0; (i) < (n1); (i)++) val[i] = a[i];
  for ((i) = 0; (i) < (n2); (i)++) val[n1 + i] = b[i];
  sort(val, val + n);
  for ((i) = 0; (i) < (n1); (i)++) a[i] = lower_bound(val, val + n, a[i]) - val;
  for ((i) = 0; (i) < (n2); (i)++) b[i] = lower_bound(val, val + n, b[i]) - val;
  string s = "";
  for ((i) = 0; (i) < (n1); (i)++) {
    char c = a[i] + '0';
    s += c;
  }
  for ((i) = 0; (i) < (n2); (i)++) {
    char c = b[i] + '0';
    s += c;
  }
  int cnt = 0;
  string s1 = s;
  while (1) {
    cnt++;
    if (s[0] > s[n1]) {
      for ((i) = 0; (i) < (n1); (i)++) s1[i] = s[i + 1];
      s1[n1] = s[0];
      for ((i) = (n1 + 1); (i) <= (n - 1); (i)++) s1[i] = s[i];
      n1++;
      n2--;
    } else {
      for ((i) = 0; (i) < (n1 - 1); (i)++) s1[i] = s[i + 1];
      for ((i) = (n1 + 1); (i) <= (n - 1); (i)++) s1[i - 2] = s[i];
      s1[n - 2] = s[0];
      s1[n - 1] = s[n1];
      n1--;
      n2++;
    }
    if (m[n1][n2].find(s1) != m[n1][n2].end()) {
      printf("-1");
      return;
    }
    if (n1 == 0) {
      printf("%d 2", cnt);
      return;
    } else if (n2 == 0) {
      printf("%d 1", cnt);
      return;
    }
    m[n1][n2][s1] = cnt;
    s = s1;
  }
}
int main() {
  input();
  return 0;
}
