#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cout << setprecision(10) << fixed;
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, 0);
  bool flag = true;
  for (int i = 0; i < m; ++i) {
    int s, c;
    cin >> s >> c;
    if (ans[s - 1] != 0) {
      flag = false;
    } else {
      ans[s - 1] = c;
    }
  }
  if (!flag) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i];
  }
  return 0;
}
