#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int S = 0;
  cin >> N >> M;
  int s[M];
  int c[M];
  for (int i = 0; i < N; i++) {
    cin >> s[i] >> c[i];
    for (int j = 0; j < i; j++) {
      if (s[i] == s[j] && c[i] == c[j]) {
        cout << "-1" << endl;
      }
    }
    S = c[i] * pow(10, (N + 1 - s[i]));
  }
  if (S / pow(10, N) == 0) {
    cout << "-1" << endl;
  } else {
    cout << S << endl;
  }
}
