#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int k1, k2;
  cin >> k1;
  queue<int> a;
  for (int i = 0; i < k1; i++) {
    int x;
    cin >> x;
    a.push(x);
  }
  cin >> k2;
  queue<int> b;
  for (int i = 0; i < k2; i++) {
    int x;
    cin >> x;
    b.push(x);
  }
  int count = 0;
  while (a.size() != 0 && b.size() != 0) {
    int temp1 = a.front();
    int temp2 = b.front();
    a.pop();
    b.pop();
    if (temp1 > temp2) {
      a.push(temp2);
      a.push(temp1);
    } else {
      b.push(temp1);
      b.push(temp2);
    }
    count++;
    if (count > 106) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (!a.empty())
    cout << count << " " << 1 << endl;
  else
    cout << count << " " << 2 << endl;
}
