#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N, M;
  cin >> N >> M;
  vector<int> A(N, -1);
  bool flag = true;
  while (M--) {
    int s, c;
    cin >> s >> c;
    s--;
    if (A[s] != -1 and A[s] != c) flag = false;
    A[s] = c;
  }
  if (!flag or A[0] == 0)
    cout << -1 << endl;
  else
    for (int x = 0; x < N; x++) {
      if (A[x] == -1 and x == 0)
        cout << 1;
      else if (A[x] == -1)
        cout << 0;
      else
        cout << A[x];
    }
  cout << endl;
  return 0;
}
