#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> ans(n + 1, -1);
  while (m--) {
    int s, c;
    cin >> s >> c;
    if (ans[s] != -1) {
      cout << "-1";
      return 0;
    }
    ans[s] = c;
  }
  for (int i = 1; i <= n; i++) {
    if (ans[i] == -1) {
      ans[i] = 0;
    }
  }
  if (ans[1] == 0) {
    cout << "-1";
  } else {
    for (int i = 1; i <= n; i++) {
      cout << ans[i];
    }
  }
}
