#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  int numCards;
  int k1;
  int k2;
  queue<int> deck1;
  queue<int> deck2;
  cin >> numCards;
  cin >> k1;
  while (k1--) {
    int card;
    cin >> card;
    deck1.push(card);
  }
  cin >> k2;
  while (k2--) {
    int card;
    cin >> card;
    deck2.push(card);
  }
  int numBattle = 0;
  while (!deck1.empty() && !deck2.empty()) {
    if (numBattle > 2000) break;
    int d1 = deck1.front();
    deck1.pop();
    int d2 = deck2.front();
    deck2.pop();
    if (d1 > d2) {
      deck1.push(d2);
      deck1.push(d1);
    } else {
      deck2.push(d1);
      deck2.push(d2);
    }
    numBattle++;
  }
  if (numBattle > 200)
    cout << -1;
  else if (deck1.empty()) {
    cout << numBattle << " " << 2 << endl;
  } else if (deck2.empty()) {
    cout << numBattle << " " << 1 << endl;
  }
}
