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