#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, s, c;
  cin >> N >> M;
  if (M == 0) {
    cout << vector<int>{0, 10, 100}[N - 1] << endl;
    return 0;
  }
  string res = string(N, '0');
  vector<bool> seen(N, false);
  while (M--) {
    cin >> s >> c;
    if (!seen[s] || res[s] > '0' + c) res[s - 1] = '0' + c;
    seen[s] = true;
  }
  if (N > 1 && res[0] == '0')
    cout << -1 << endl;
  else
    cout << res << endl;
  return 0;
}
