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