#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<char> v(n);
  int s, res = 0;
  char c;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    if (s == 1 && c == '0') {
      res = -1;
      break;
    }
    if (v[s - 1] == 0 || v[s - 1] == c) {
      v[s - 1] = c;
    } else {
      res = -1;
      break;
    }
  }
  int check = 0;
  if (res == 0) {
    for (int i = 0; i < n; i++) {
      if (v[i] == 0) {
        if (i == 0) {
          cout << "1";
        } else {
          cout << "0";
        }
      } else {
        cout << v[i];
      }
    }
    cout << endl;
  } else
    cout << "-1" << endl;
  return 0;
}
