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