#include <bits/stdc++.h>
using namespace std;
queue<int> q1, q2;
int n, k1, k2;
set<pair<int, int> > s;
int main() {
  cin >> n;
  cin >> k1;
  for (int i = 0; i < k1; i++) {
    int p;
    cin >> p;
    q1.push(p);
  }
  cin >> k2;
  for (int i = 0; i < k2; i++) {
    int p;
    cin >> p;
    q2.push(p);
  }
  int i;
  for (i = 0; i < 1 << 20; i++) {
    if (q1.size() == 0 || q2.size() == 0) break;
    int f, s;
    f = q1.front();
    q1.pop();
    s = q2.front();
    q2.pop();
    if (f > s) {
      q1.push(s);
      q1.push(f);
    } else {
      q2.push(f);
      q2.push(s);
    }
  }
  if (q1.size() == 0)
    cout << i << " " << 2;
  else if (q2.size() == 0)
    cout << i << " " << 1;
  else
    cout << -1;
  return 0;
}
