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