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