#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, 0);
  int cnt = 0;
  bool ok = true;
  for (int i = 0; i < (int)(m); i++) {
    int s, c;
    cin >> s >> c;
    ans[s - 1] = c;
  }
  if (ans[0] == 0) ok = false;
  if (ok) {
    for (int i = 0; i < (int)(n); i++) cout << ans[i];
  } else {
    cout << -1;
  }
  cout << endl;
  return 0;
}
