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