#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, flag = 1;
  cin >> n >> m;
  string ans = "0100";
  for (int i = 0; i < m; i++) {
    int in, num;
    cin >> in >> num;
    if (in == 1 && ans[in] == '1') {
      ans[in] = num + '0';
    } else if (in == 1 && ans[in] != num + '0') {
      flag = 0;
      break;
    } else if (ans[in] == '0' && in != 1) {
      ans[in] = num + '0';
    } else if (ans[in] != num + '0' && in != 1) {
      flag = 0;
      break;
    }
  }
  if (n == 1) {
    return cout << (flag ? "1" : "0"), 0;
  }
  if (!flag) return cout << "-1", 0;
  if (ans[1] == '0') return cout << "-1", 0;
  for (int i = 1; i <= n; i++) cout << ans[i];
}
