#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int setup(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  return 0;
}
int lenght(char* str) {
  int i = 0;
  while (str[i]) i++;
  return i;
}
int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
int iinput(void) {
  int a = 0;
  cin >> a;
  return a;
}
int dinput(void) {
  double a = 0;
  cin >> a;
  return a;
}
string sinput(void) {
  string a = "";
  cin >> a;
  return a;
}
int kuriup(double a) {
  int b = int(a);
  if (a != b) {
    return b + 1;
  } else {
    return b;
  }
}
int kuridown(double a) {
  int b = int(a);
  return b;
}
int run(void);
int main() {
  setup();
  run();
  return 0;
}
struct nums {
  int s;
  int c;
};
bool paircompare(const pair<int, int>& firstelof,
                 const pair<int, int>& secondelof) {
  return firstelof.first > secondelof.second;
}
int run(void) {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> pairs(m);
  for (int i = 0; i < m; i++) {
    cin >> pairs[i].first >> pairs[i].second;
  }
  string word = "";
  for (int i = 0; i < n; i++) word += "0";
  if (m == 0) {
    cout << '1' + word.substr(1, m - 1) << endl;
    return 0;
  }
  for (int i = 0; i < m; i++) {
    word = word.substr(0, pairs[i].first - 1) + to_string(pairs[i].second) +
           word.substr(pairs[i].first, m - pairs[i].first);
    if (pairs[i].first == 1 && pairs[i].second == 0) {
      cout << "-1" << endl;
      return 0;
    }
  }
  sort(pairs.begin(), pairs.end(), paircompare);
  for (int i = 0; i < n; i++) {
    if (pairs[i].first == pairs[i + 1].first &&
        pairs[i].second != pairs[i + 1].second) {
      cout << "-1" << endl;
      return 0;
    }
  }
  if (word[0] == '0') {
    word = '1' + word.substr(1, n - 1);
  }
  cout << word << endl;
  return 0;
}
