#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  string s = "1";
  if (n == 2)
    s = "10";
  else if (n == 3)
    s = "100";
  vector<long long> used(10, -1);
  long long flg = 0;
  for (long long i = 0; i < (long long)m; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    if (used[a] != -1 && used[a] != b) {
      flg = -1;
    }
    used[a] = b;
    s[a] = b + '0';
  }
  if (flg == 0 && s == "0")
    ;
  else if (s[0] == '0')
    flg = -1;
  if (flg == -1)
    cout << -1 << endl;
  else
    cout << s << endl;
}
