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