#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string res = "1";
  if (n == 2) res = "10";
  if (n == 3) res = "100";
  bool isfix[3] = {false, false, false};
  for (int i = 0; i < (m); ++i) {
    int s;
    char c;
    cin >> s >> c;
    --s;
    if ((s == 0 && c == '0') || (isfix[s] && res[s] != c)) {
      cout << -1 << endl;
      return 0;
    }
    res[s] = c;
    isfix[s] = true;
  }
  cout << res << endl;
  return 0;
}
