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