#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  set<int> s;
  set<pair<int, int>> conditions;
  for (int i = 0; i < M; ++i) {
    int si, ci;
    cin >> si >> ci;
    s.insert(si);
    conditions.insert({si, ci});
  }
  if (s.size() != conditions.size() || M > N)
    cout << -1;
  else if (M == 0)
    cout << 0;
  else {
    vector<pair<int, int>> pCond(conditions.begin(), conditions.end());
    sort(pCond.begin(), pCond.end());
    string result = "";
    int cPos = 1;
    for (unsigned int i = 0; i < pCond.size(); ++i) {
      int si = pCond[i].first;
      int ci = pCond[i].second;
      if (si == 1 && ci == 0 && N == 1) {
        cout << 0;
        break;
      }
      if (si == 1 && ci == 0 && N > 1) {
        cout << -1;
        break;
      }
      if (cPos == si) {
        result += '0' + ci;
        cPos++;
        continue;
      } else {
        while (cPos < si) {
          if (cPos == 1)
            result += '1';
          else
            result += '0';
          cPos++;
        }
        result += '0' + ci;
        cPos++;
      }
    }
    while (result.size() < N) result += '0';
    cout << result;
  }
}
