#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S(M), C(M);
  for (int i = 0; i < (M); i++) cin >> S[i] >> C[i];
  int ans = 1;
  vector<int> X(N);
  for (int i = 0; i < (N); i++) X[i] = -1;
  for (int i = 0; i < (M); i++) {
    if (X[S[i] - 1] == -1) {
      X[S[i] - 1] = C[i];
      if (S[i] - 1 == 0 && C[i] == 0) ans = 0;
    } else {
      if (X[S[i] - 1] != C[i]) ans = 0;
    }
  }
  if (ans) {
    if (M) {
      for (int i = 0; i < (N); i++) {
        if (X[i] != -1)
          cout << X[i];
        else if (i == 0)
          cout << 1;
        else
          cout << 0;
      }
      cout << endl;
    } else {
      for (int i = 0; i < (N); i++) {
        if (i)
          cout << 0;
        else
          cout << 1;
      }
      cout << endl;
    }
  } else
    cout << -1 << endl;
}
