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