#include <bits/stdc++.h>
using namespace std;
struct Data {
  int number;
  int order;
};
int main() {
  int N, M;
  char s[3];
  Data A[5];
  scanf("%d %d\n", &N, &M);
  cout << N, M;
  for (int i = 0; i < M; i++) {
    scanf("%d %d\n", &A[i].order, &A[i].number);
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      if (A[i].order == A[j].order && i != j) {
        cout << -1;
        return 0;
      }
    }
  }
  return 0;
}
