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