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