#include <bits/stdc++.h>
using namespace std;
int n, m;
int c[109];
int st[109];
int mp[109];
string s;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cin >> n >> m;
  for (int i = 0; i < n; i++) s += '0';
  for (int i = 0; i < m; i++) {
    cin >> st[i] >> c[i];
  }
  for (int i = 0; i < m; i++) {
    if (mp[st[i]] && s[st[i] - 1] != c[i] + '0') {
      cout << "-1" << endl;
      return 0;
    }
    mp[st[i]] = 1, s[st[i] - 1] = c[i] + '0';
  }
  if (s[0] == '0') {
    if (mp[1])
      cout << "-1" << endl;
    else
      s[0] = '1', cout << s << endl;
  } else
    cout << s << endl;
}
