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