#include <bits/stdc++.h>
using namespace std;
queue<int> one, two;
int main() {
  int n, a;
  cin >> n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    one.push(a);
  }
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    two.push(a);
  }
  int b;
  for (int i = 0; i < 5000000; i++) {
    if (one.empty()) {
      cout << i << " " << 2;
      return 0;
    }
    if (two.empty()) {
      cout << i << " " << 1;
      return 0;
    }
    a = one.front();
    b = two.front();
    one.pop();
    two.pop();
    if (a < b) {
      two.push(a);
      two.push(b);
    } else {
      one.push(b);
      one.push(a);
    }
  }
  cout << -1;
}
