#include <bits/stdc++.h>
using namespace std;
int main() {
  string s = "100";
  int n, m, c;
  cin >> n >> m;
  if (n == 1)
    s = "1";
  else if (n == 2)
    s = "10";
  vector<bool> b(n, false);
  char t;
  bool k = true;
  for (int i = 0; i < m; i++) {
    cin >> c >> t;
    if (c == 1 && t == '0' && n != 1)
      k = false;
    else if (c == 1 && t == '0' && n == 1 && !b[c - 1]) {
      s = '0';
      break;
    } else if (!b[c - 1]) {
      b[c - 1] = true;
      s[c - 1] = t;
    } else if (s[c - 1] != t)
      k = false;
    else if (c == 1 && t == '0')
      k = false;
  }
  if (k)
    cout << s << endl;
  else
    cout << -1 << endl;
}
