#include <bits/stdc++.h>
using namespace std;
void Main() {
  long long N, M, s, t;
  cin >> N >> M;
  if (N > 1 && M == 0) {
    cout << "-1" << endl;
  } else if (N == 1 && M == 0) {
    cout << "0" << endl;
  } else {
    map<long long, long long> q;
    vector<char> ans(N, '0');
    ans[0] = '1';
    bool is_ok = true;
    for (long long i = 0; i < M; ++i) {
      cin >> s >> t;
      if (q.find(s) != q.end() && q[s] != t) {
        is_ok = false;
      }
      q[s] = t;
    }
    if (is_ok) {
      string a = "";
      for (auto p : q) {
        ans[p.first - 1] = '0' + p.second;
      }
      for (auto s : ans) {
        a += s;
      }
      if (a[0] == '0' && N > 1) {
        cout << "-1" << endl;
      } else {
        cout << a << endl;
      }
    } else {
      cout << "-1" << endl;
    }
  }
}
int main() { Main(); }
