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