#include <bits/stdc++.h>
using namespace std;
string solve() {
  int N, M;
  cin >> N >> M;
  string ans(N, ' ');
  for (int i = 0, s, c; i < M; i++) {
    cin >> s >> c;
    if (ans[s - 1] == ' ')
      ans[s - 1] = c + '0';
    else if (ans[s - 1] != c + '0') {
      return "-1";
    }
  }
  for (int i = 0; i < N; i++) {
    if (ans[i] == ' ') ans[i] = i == 0 ? '1' : '0';
    if (ans.length() == 1) ans[i] = '0';
  }
  if (ans.length() > 1 &&
      all_of(ans.begin(), ans.end(), [](char c) { return c == '0'; }))
    return "-1";
  return ans;
}
int main() { cout << solve() << endl; }
