#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;
  string res = string(N, '0');
  while (M--) {
    cin >> s >> c;
    res[s - 1] = '0' + c;
  }
  if (N > 1 && res[0] == '0')
    cout << -1 << endl;
  else
    cout << res << endl;
  return 0;
}
