#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, m;
  cin >> n >> m;
  if (n == 1 and m == 0) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; i++) s += '0';
  for (int i = 0; i < m; i++) {
    int ind;
    char c;
    cin >> ind >> c;
    if (s[ind - 1] == '0')
      s[ind - 1] = c;
    else if (s[ind - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (s[0] == '0' and n >= 2) {
    cout << -1 << endl;
    return 0;
  }
  if (s[0] == '0') s[0] = '1';
  cout << s << endl;
}
