#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    string s;
    s.resize(n);
    while (m--) {
      long long d;
      char c;
      cin >> d >> c;
      if (not s[d - 1]) {
        s[d - 1] = c;
        if (d == 1 and c == '0') {
          puts("-1");
          return 0;
        }
      } else {
        if ((s[d - 1] and s[d - 1] != c)) {
          puts("-1");
          return 0;
        }
      }
    }
    for (auto &c : s) {
      if (not c) c = '0';
    }
    if (s[0] == '0') s[0] = '1';
    cout << s << endl;
  }
}
