#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int k1, k2;
  cin >> k1;
  queue<int> q1, q2;
  for (int i = 0; i < k1; i++) {
    int x;
    cin >> x;
    q1.push(x);
  }
  cin >> k2;
  for (int i = 0; i < k2; i++) {
    int x;
    cin >> x;
    q2.push(x);
  }
  long no = 0;
  while (no < (n * n + n) && !q2.empty() && !q1.empty()) {
    if (q2.front() < q1.front()) {
      int x = q2.front();
      q2.pop();
      int y = q1.front();
      q1.pop();
      q1.push(x);
      q1.push(y);
    } else {
      int x = q2.front();
      q2.pop();
      int y = q1.front();
      q1.pop();
      q2.push(y);
      q2.push(x);
    }
    no++;
  }
  if (no >= (n * n + n))
    cout << -1 << endl;
  else {
    if (q1.empty()) {
      cout << no << " " << 2;
    } else
      cout << no << " " << 1;
  }
  return 0;
}
