#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, n1, n2, x, y, ans = 0, dap[15][15];
  queue<int> p;
  queue<int> q;
  cin >> n;
  cin >> n1;
  memset(dap, 0, sizeof(dap));
  for (int i = 0; i < n1; i++) {
    cin >> x;
    p.push(x);
  }
  cin >> n2;
  for (int i = 0; i < n2; i++) {
    cin >> x;
    q.push(x);
  }
  while (!p.empty() && !q.empty()) {
    x = p.front();
    p.pop();
    y = q.front();
    q.pop();
    ans++;
    dap[x][y]++;
    if (dap[x][y] > 100) {
      cout << -1 << endl;
      return 0;
    }
    if (x > y) {
      p.push(y);
      p.push(x);
    } else {
      q.push(x);
      q.push(y);
    }
  }
  if (!p.empty()) {
    cout << ans << " " << 1 << endl;
  }
  if (!q.empty()) {
    cout << ans << " " << 2 << endl;
  }
  return 0;
}
