#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  string str(N, 0);
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    if ((s == 1 and c == 0) or (str[s - 1] != 0 and str[s - 1] != '0' + c)) {
      cout << -1 << endl;
      return 0;
    }
    str[s - 1] = '0' + c;
  }
  for (auto& c : str)
    if (c == 0) c = '0';
  if (str[0] == '0') str[0] = '1';
  cout << str << endl;
  return 0;
}
