#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  string s = "";
  for (int i = 0; i < n; i++) s += '*';
  while (m--) {
    int pos;
    char c;
    cin >> pos >> c;
    pos--;
    if (s[pos] == '*')
      s[pos] = c;
    else if (s[pos] != c) {
      cout << -1 << endl;
      return 0;
    }
    if (pos == 0 && c == '0') {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == '*') {
      if (i == 0)
        cout << 1;
      else
        cout << 0;
    } else {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}
