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