#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
int main() {
  long long n, m;
  cin >> n >> m;
  long long s[m], c[m];
  for (int i = 0; i < m; i++) cin >> s[i] >> c[i];
  set<long long> co[3];
  for (int i = 0; i < m; i++) co[s[i] - 1].insert(c[i]);
  bool si = true;
  for (int i = 0; i < m; i++)
    if (co[i].size() >= 2) si = false;
  bool sii = false;
  vector<long long> ans;
  if (si) {
    for (int i = 0; i < n; i++) {
      bool siii = false;
      for (int j = 0; j < m; j++) {
        if (s[j] == i + 1) {
          ans.push_back(c[j]);
          sii = true;
          siii = true;
          break;
        }
      }
      if (!siii) {
        if (sii) {
          ans.push_back(0);
        } else {
          ans.push_back(1);
          sii = true;
        }
      }
    }
    if (ans[0] == 0 && ans.size() > 1) {
      cout << -1 << endl;
    } else {
      for (int i = 0; i < n; i++) {
        cout << ans[i];
      }
      cout << endl;
    }
  } else {
    cout << -1 << endl;
  }
}
