#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string ans;
  if (n == 3) {
    ans = "100";
  } else if (n == 2) {
    ans = "10";
  } else {
    ans = "1";
  }
  vector<int> test(n);
  for (int i = 0; i < (int)(n); i++) {
    test.at(i) = 0;
  }
  for (int i = 0; i < (int)(m); i++) {
    int s, c;
    cin >> s >> c;
    s--;
    if (ans.at(s) != c) {
      if (test.at(s) == 0) {
        ans.at(s) = c;
        test.at(s)++;
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  int ansu = stoi(ans);
  cout << ansu << endl;
  return 0;
}
