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