#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, flag = 1, count = 0;
  cin >> n >> m;
  char ans[n];
  memset(ans, '0', n);
  int s[m];
  char c[m];
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> c[i];
    if (s[i] == 1 && int(c[i]) == 48) flag = 0;
    ans[s[i] - 1] = c[i];
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == ' ' && i == 0) ans[i] = '1';
    if (ans[i] == ' ') count++;
  }
  if (count == n) {
    if (n == 3 && ans != "100") flag = 0;
    if (n == 2 && ans != "10") flag = 0;
    if (n == 1 && ans != "1") flag = 0;
  }
  if (flag) {
    for (int i = 0; i < n; i++) cout << ans[i];
  } else
    cout << -1;
  return 0;
}
