#include <bits/stdc++.h>
using namespace std;
void test_case() {}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int s;
  char c;
  vector<pair<int, char> > req;
  for (int i = int(0); i < int(m); i++) {
    cin >> s >> c;
    req.push_back({s, c});
  }
  string res = "";
  for (int i = int(0); i < int(n); i++) res += 'a';
  bool flag = true;
  for (int i = int(0); i < int(m); i++) {
    s = req[i].first;
    c = req[i].second;
    s--;
    if (res[s] != 'a') {
      if (res[s] != c) {
        res = "-1";
        i = m + 1;
        flag = false;
        break;
      }
    }
    if (s == 0 && c == '0') {
      res = "-1";
      break;
    }
    if (flag == true) res[s] = c;
  }
  if (res != "-1") {
    for (int i = int(0); i < int(n); i++) {
      if (res[i] == 'a') {
        if (i == 0)
          res[i] = '1';
        else
          res[i] = '0';
      }
    }
  }
  cout << res << endl;
  return 0;
}
