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