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