#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  bool flag = false;
  vector<int> ans(n + 1, -1);
  for (long long i = 0; i < (long long)(m); i++) {
    int s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) {
      flag = true;
      break;
    } else if (ans[s] == c)
      continue;
    else if (ans[s] != -1) {
      flag = true;
      break;
    } else {
      ans[s] = c;
    }
  }
  if (ans[1] == -1) {
    ans[1] = 1;
  }
  for (long long i = 0; i < (long long)(n + 1); i++) {
    if (ans[i] == -1) {
      ans[i] = 0;
    }
  }
  if (flag) {
    cout << -1 << endl;
  } else {
    for (long long i = (long long)(1); i < (long long)(n + 1); i++) {
      cout << ans[i];
    }
    cout << endl;
  }
}
