#include <bits/stdc++.h>
using namespace std;
long long n, m;
string S = "100";
bool b[3];
signed main() {
  cin >> n >> m;
  if (n == 1) S = "1";
  if (n == 2) S = "10";
  for (long long i = 0; i < (long long)(m); ++i) {
    long long s, c;
    cin >> s >> c;
    if (s == 1 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    --s;
    if (b[s]) {
      if (S[s] != c + '0') {
        cout << -1 << endl;
        return 0;
      }
    } else {
      S[s] = c + '0';
      b[s] = true;
    }
  }
  cout << S << endl;
}
