#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  string ans = "";
  for (int i = 0; i < n; i++) ans += 'x';
  for (int i = 0; i < m; i++) {
    int a;
    char b;
    cin >> a >> b;
    a--;
    if (ans[a] != 'x' and ans[a] != b) {
      cout << "-1" << endl;
      return 0;
    }
    ans[a] = b;
  }
  if (ans[0] == '0' and n != 1) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] != 'x') continue;
    if (!i)
      ans[i] = '1';
    else
      ans[i] = '0';
  }
  cout << ans << endl;
}
