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