#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    if (N == 1) cout << "0" << endl;
    if (N == 2) cout << "10" << endl;
    if (N == 3) cout << "100" << endl;
  } else {
    vector<pair<int, int>> a(M);
    for (int i = 0; i < M; i++) cin >> a.at(i).first >> a.at(i).second;
    sort(a.begin(), a.end());
    if (a.at(0) == make_pair(1, 0))
      cout << "-1" << endl;
    else {
      bool x = false;
      for (int i = 1; i < M; i++)
        for (int j = 0; j < i; j++) {
          if (a.at(i).first == a.at(j).first &&
              a.at(i).second != a.at(j).second)
            x = true;
        }
      if (x)
        cout << "-1" << endl;
      else {
        vector<int> m(N, 0);
        for (int i = 0; i < M; i++) {
          m.at(a.at(i).first - 1) = a.at(i).second;
        }
        for (int i = 0; i < N; i++) cout << m.at(i);
        cout << endl;
      }
    }
  }
}
