#include <bits/stdc++.h>
using namespace std;
deque<int> A, B;
long long p, i, j, k, n, m, aux;
long long fact(int a) {
  long long f = 1;
  int i;
  for (int i = (int)(1); i <= (int)(a); ++i) f *= i;
  return f;
}
int main(void) {
  cin >> p;
  cin >> n;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    cin >> aux;
    A.push_back(aux);
  }
  cin >> n;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    cin >> aux;
    B.push_back(aux);
  }
  long long step(0);
  long long stari = fact(p + 1);
  while (step <= stari) {
    if (A.empty()) return cout << step << " " << 2, 0;
    if (B.empty()) return cout << step << " " << 1, 0;
    ++step;
    int x = A.front();
    A.pop_front();
    int y = B.front();
    B.pop_front();
    if (x < y) {
      B.push_back(x);
      B.push_back(y);
    } else {
      A.push_back(y);
      A.push_back(x);
    }
  }
  cout << "-1";
  return 0;
}
