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