#include <bits/stdc++.h>
using namespace std;
int F;
queue<int> Q1, Q2;
map<pair<int, int>, int> X;
int cnt;
int bfs() {
  int times = 500000;
  while (times--) {
    int x1 = Q1.front();
    int x2 = Q2.front();
    Q1.pop();
    Q2.pop();
    if (x1 > x2) {
      Q1.push(x2);
      Q1.push(x1);
      X[make_pair(x1, x2)] = 1;
      cnt++;
    } else if (x1 < x2) {
      Q2.push(x1);
      Q2.push(x2);
      X[make_pair(x2, x1)] = 1;
      cnt++;
    }
    if (Q1.empty()) {
      cout << cnt << " " << '2';
      exit(0);
    } else if (Q2.empty()) {
      cout << cnt << " " << '1';
      exit(0);
    }
  }
}
int main() {
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < x; i++) {
    int L;
    cin >> L;
    Q1.push(L);
  }
  cin >> x;
  for (int i = 0; i < x; i++) {
    int L;
    cin >> L;
    Q2.push(L);
  }
  bfs();
  cout << "-1";
}
