#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, n1, n2, limiter = 1, fight = 0, temp;
  cin >> n >> n1;
  queue<int> p1, p2;
  for (int i = 1; i <= n1; i++) {
    cin >> temp;
    p1.push(temp);
    limiter *= i;
  }
  cin >> n2;
  for (int i = 1; i <= n2; i++) {
    cin >> temp;
    p2.push(temp);
    limiter *= (n1 + i);
  }
  limiter *= (n + 1);
  while (1) {
    if (fight > limiter) {
      cout << -1;
      break;
    } else if (p1.empty()) {
      cout << fight << " " << 2;
      break;
    } else if (p2.empty()) {
      cout << fight << " " << 1;
      break;
    } else {
      if (p1.front() > p2.front()) {
        p1.push(p2.front());
        p1.push(p1.front());
        p1.pop();
        p2.pop();
        fight++;
      } else {
        p2.push(p1.front());
        p2.push(p2.front());
        p2.pop();
        p1.pop();
        fight++;
      }
    }
  }
}
