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