#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, 0);
  for (ll i = 0; i < (m); i++) {
    int s, c;
    cin >> s >> c;
    ans[s - 1] = c;
  }
  if (ans[0] == 0) {
    cout << -1 << '\n';
    return 0;
  }
  for (ll i = 0; i < (n); i++) cout << ans[i];
  cout << '\n';
  return 0;
}
