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