#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k1, k2, i, t, count, c1, c2;
  vector<long long> a, b;
  cin >> n;
  cin >> k1;
  for (i = 0; i < k1; i++) {
    cin >> t;
    a.push_back(t);
  }
  cin >> k2;
  for (i = 0; i < k2; i++) {
    cin >> t;
    b.push_back(t);
    count = 0;
  }
  for (i = 0; i <= 10000; i++) {
    if (*a.begin() > *b.begin()) {
      c1 = *a.begin();
      c2 = *b.begin();
      a.erase(a.begin());
      a.push_back(c2);
      a.push_back(c1);
      b.erase(b.begin());
      count++;
      if (b.empty()) {
        cout << count << " " << 1 << endl;
        return 0;
      }
    } else {
      c1 = *b.begin();
      c2 = *a.begin();
      b.erase(b.begin());
      b.push_back(c2);
      b.push_back(c1);
      a.erase(a.begin());
      count++;
      if (a.empty()) {
        cout << count << " " << 2 << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}
