#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
const int mINF = -1001001001;
int main() {
  int n, m;
  cin >> n >> m;
  int s;
  char c;
  char ans[n];
  for (int i = 0; i < (n); i++) ans[i] = 'x';
  int x;
  bool flg = true;
  for (int i = 0; i < (m); i++) {
    cin >> s >> c;
    s--;
    if (ans[s] == 'x') {
      ans[s] = c;
    } else if (ans[x] != c) {
      flg = false;
    }
  }
  if (ans[0] == 0) flg = false;
  if (flg == true) {
    for (int i = 0; i < (n); i++) {
      if (ans[i] == 'x') {
        if (i == 0) {
          cout << "1";
        } else {
          cout << "0";
        }
      } else {
        cout << ans[i];
      }
    }
    cout << endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}
