#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<utility>
#include<vector>
#include<set>
//#include<stack>
//#include <sstream>
//#include<queue>
typedef long long ll;
using namespace std;
const int N = 1e5 + 7;
int n, x[N], q, m[N], freq[N], ans, j;
vector<pair<int, int>>pair1;
int search(int arr[], int num, int L, int R, bool flag = false) {
	int mid = 0;
	if (R >= L) {
		mid = L + (R - L) / 2;
		if (num == arr[mid])
			return mid + 1;
		else if (num > arr[mid]) {

			return search(arr, num, mid + 1, R, true);
		}
		else {
			return search(arr, num, L, mid - 1, true);
		}
	}
	//cout << "ans : " << L << " " << R << " " << mid << endl;
	if (L > -1 && num >= arr[L - 1]) {
		if (L > j)
			return L - 1;
		return L;
	}
	else if (R > -1 && num >= arr[R])
		return R;
	else
		return 0;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	sort(x, x + n);
	for (int i = 0; i < n; i++) {
		if (!pair1.empty()) {
			if (pair1[pair1.size() - 1].first == x[i]) {
				pair1[pair1.size() - 1].second = i + 1;
				continue;
			}
			else {
				if(pair1[pair1.size() - 1].second < 2)
				pair1.pop_back();
			}
		}
		pair1.push_back({ x[i], i +1});
	}
	j = n;
	for (size_t i = 0; i < pair1.size(); i++)
	{
		cout << pair1[i].first << " " << pair1[i].second << endl;
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m[i];
		ans = search(x, m[i], 0, n);
		//cout << ans << endl;
		for (int i = 0; i < pair1.size(); i++)
		{
			if (x[ans-1] == pair1[i].first) {
				//cout << "pair : " << x[ans] << " " << pair1[i].first << " ";
				ans = pair1[i].second;
				break;
			}
		}
		cout << ans << "\n";
	}
	return 0;
}


#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<utility>
#include<vector>
#include<set>
//#include<stack>
//#include <sstream>
//#include<queue>
typedef long long ll;
using namespace std;
const int N = 1e6 + 7;
template<class t>
class queue {
private:
	struct node {
		t item;
		node* next;
	};
	node* front;
	node* rear;
	int length;
public:
	queue() {
		front = rear = NULL;
		length = 0;
	}
	void enqueue(t el) {
		node* newItem = new node;
		newItem->item = el;
		newItem->next = NULL;
		if (isEmpty()) {
			front = rear = newItem;
		}
		else {
			rear->next = newItem;
			rear = newItem;
		}
		length++;
	}
	void dequeue() {
		if (isEmpty()) {
			cout<<"The queue is Empty\n";
		}
		else if(rear == front){
			delete front;
			rear = NULL;
		}
		else {
			node* temp = front;
			front = front->next;
			delete temp;
		}
		length--;
	}

	void print() {
		if (!isEmpty()) {
			cout << "[ ";
			for (node* cur = front; cur != NULL; cur = cur->next) {
				cout << cur->item << " ";
			}
			cout << "]\n";
		}
	}
	bool isEmpty() {
		return rear == NULL;
	}

};
int search(int arr[], int num, int L, int R, bool flag = false) {
	int mid = 0;
	if (R >= L) {
		mid = L + (R - L) / 2;
		if (num == arr[mid])
			return mid + 1;
		else if (num > arr[mid]) {
			if (num < arr[mid+1])
				return mid+1;
			return search(arr, num, mid + 1, R, true);
		}
		else {
			if (mid > -1)
				if (num >= arr[mid - 1])
					return mid;
			return search(arr, num, L, mid - 1, true);
		}

	}
	if (R > -1)
		return R +1;
	else
		return 0;
}
int n, x[N], q, m[N];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	sort(x, x + n);
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m[i];
		cout <<search(x, m[i], 0, n -1)<<endl;
	}
	return 0;
}


#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<utility>
#include<vector>
#include<set>
//#include<stack>
//#include <sstream>
//#include<queue>
typedef long long ll;
using namespace std;
const int N = 1e6 + 7;
template<class t>
class queue {
private:
	struct node {
		t item;
		node* next;
	};
	node* front;
	node* rear;
	int length;
public:
	queue() {
		front = rear = NULL;
		length = 0;
	}
	void enqueue(t el) {
		node* newItem = new node;
		newItem->item = el;
		newItem->next = NULL;
		if (isEmpty()) {
			front = rear = newItem;
		}
		else {
			rear->next = newItem;
			rear = newItem;
		}
		length++;
	}
	void dequeue() {
		if (isEmpty()) {
			cout<<"The queue is Empty\n";
		}
		else if(rear == front){
			delete front;
			rear = NULL;
		}
		else {
			node* temp = front;
			front = front->next;
			delete temp;
		}
		length--;
	}

	void print() {
		if (!isEmpty()) {
			cout << "[ ";
			for (node* cur = front; cur != NULL; cur = cur->next) {
				cout << cur->item << " ";
			}
			cout << "]\n";
		}
	}
	bool isEmpty() {
		return rear == NULL;
	}

};
int search(int arr[], int num, int L, int R, bool flag = false) {
	int mid = 0;
	if (R >= L) {
		mid = L + (R - L) / 2;
		if (num == arr[mid])
			return mid + 1;
		else if (num > arr[mid]) {
			return search(arr, num, mid + 1, R, true);
		}
		else {
			return search(arr, num, L, mid - 1, true);
		}

	}
	if (num >= arr[L])
		return L;
	else
		return 0;
}

int n, x[N], q, m[N];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	sort(x, x + n);
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m[i];
		cout <<search(x, m[i], 0, n -1)<<endl;
	}
	return 0;
}


#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<utility>
#include<vector>
#include<set>
//#include<stack>
//#include <sstream>
//#include<queue>
typedef long long ll;
using namespace std;
const int N = 1e5 + 7;
template<class t>
class queue {
private:
	struct node {
		t item;
		node* next;
	};
	node* front;
	node* rear;
	int length;
public:
	queue() {
		front = rear = NULL;
		length = 0;
	}
	void enqueue(t el) {
		node* newItem = new node;
		newItem->item = el;
		newItem->next = NULL;
		if (isEmpty()) {
			front = rear = newItem;
		}
		else {
			rear->next = newItem;
			rear = newItem;
		}
		length++;
	}
	void dequeue() {
		if (isEmpty()) {
			cout << "The queue is Empty\n";
		}
		else if (rear == front) {
			delete front;
			rear = NULL;
		}
		else {
			node* temp = front;
			front = front->next;
			delete temp;
		}
		length--;
	}

	void print() {
		if (!isEmpty()) {
			cout << "[ ";
			for (node* cur = front; cur != NULL; cur = cur->next) {
				cout << cur->item << " ";
			}
			cout << "]\n";
		}
	}
	bool isEmpty() {
		return rear == NULL;
	}

};

int n, x[N], q, m[N], freq[N], ans, j;
vector<pair<int, int>>pair1;
int search(int arr[], int num, int L, int R, bool flag = false) {
	int mid = 0;
	if (R >= L) {
		mid = L + (R - L) / 2;
		if (num == arr[mid])
			return mid + 1;
		else if (num > arr[mid]) {

			return search(arr, num, mid + 1, R, true);
		}
		else {
			return search(arr, num, L, mid - 1, true);
		}

	}
	cout << "ans : " << L << " " << R << " " << mid << endl;
	if (L > -1 && num >= arr[L - 1]) {
		if (L > j)
			return L - 1;
		return L;
	}

	else if (R > -1 && num >= arr[R])
		return R;
	else
		return 0;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	sort(x, x + n);
	for (int i = 0; i < n; i++) {
		if (i > 0) {
			if (pair1[i-1].first == x[i])
				pair1.pop_back();
		}
		pair1.push_back({ x[i], i + 1 });
	}
	j = n;

	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m[i];
		ans = search(x, m[i], 0, n);
		/*
		for (int i = 0; i < pair1.size(); i++)
		{
			if (x[ans] == pair1[i].first) {
				cout << "pair : " << x[ans] << " " << pair1[i].first << " ";
				ans = pair1[i].second;

				break;
			}
		}*/
		cout << ans << endl;
	}
	return 0;
}


#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<utility>
#include<vector>
#include<set>
//#include<stack>
//#include <sstream>
//#include<queue>
typedef long long ll;
using namespace std;
const int N = 1e6 + 7;
template<class t>
class queue {
private:
	struct node {
		t item;
		node* next;
	};
	node* front;
	node* rear;
	int length;
public:
	queue() {
		front = rear = NULL;
		length = 0;
	}
	void enqueue(t el) {
		node* newItem = new node;
		newItem->item = el;
		newItem->next = NULL;
		if (isEmpty()) {
			front = rear = newItem;
		}
		else {
			rear->next = newItem;
			rear = newItem;
		}
		length++;
	}
	void dequeue() {
		if (isEmpty()) {
			cout<<"The queue is Empty\n";
		}
		else if(rear == front){
			delete front;
			rear = NULL;
		}
		else {
			node* temp = front;
			front = front->next;
			delete temp;
		}
		length--;
	}

	void print() {
		if (!isEmpty()) {
			cout << "[ ";
			for (node* cur = front; cur != NULL; cur = cur->next) {
				cout << cur->item << " ";
			}
			cout << "]\n";
		}
	}
	bool isEmpty() {
		return rear == NULL;
	}

};
int search(int arr[], int num, int L, int R, bool flag = false) {
	int mid = 0;
	if (R >= L) {
		mid = L + (R - L) / 2;
		if (num == arr[mid])
			return mid + 1;
		else if (num > arr[mid]) {
			return search(arr, num, mid + 1, R, true);
		}
		else {
			return search(arr, num, L, mid - 1, true);
		}

	}
	if (R > -1)
		return R +1;
	else
		return 0;
}

int n, x[N], q, m[N];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	sort(x, x + n);
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m[i];
		cout <<search(x, m[i], 0, n -1)<<endl;
	}
	return 0;
}


#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<utility>
#include<vector>
#include<set>
//#include<stack>
//#include <sstream>
//#include<queue>
typedef long long ll;
using namespace std;
const int N = 1e6 + 7;
template<class t>
class queue {
private:
	struct node {
		t item;
		node* next;
	};
	node* front;
	node* rear;
	int length;
public:
	queue() {
		front = rear = NULL;
		length = 0;
	}
	void enqueue(t el) {
		node* newItem = new node;
		newItem->item = el;
		newItem->next = NULL;
		if (isEmpty()) {
			front = rear = newItem;
		}
		else {
			rear->next = newItem;
			rear = newItem;
		}
		length++;
	}
	void dequeue() {
		if (isEmpty()) {
			cout<<"The queue is Empty\n";
		}
		else if(rear == front){
			delete front;
			rear = NULL;
		}
		else {
			node* temp = front;
			front = front->next;
			delete temp;
		}
		length--;
	}

	void print() {
		if (!isEmpty()) {
			cout << "[ ";
			for (node* cur = front; cur != NULL; cur = cur->next) {
				cout << cur->item << " ";
			}
			cout << "]\n";
		}
	}
	bool isEmpty() {
		return rear == NULL;
	}

};
int search(int arr[], int num, int L, int R, bool flag = false) {
	int mid = 0;
	if (R >= L) {
		mid = L + (R - L) / 2;
		if (num == arr[mid])
			return mid + 1;
		else if (num > arr[mid]) {
			return search(arr, num, mid + 1, R, true);
		}
		else {
			return search(arr, num, L, mid - 1, true);
		}

	}
	if (num > arr[mid])
		return L;
	else
		return 0;
}

int n, x[N], q, m[N];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	sort(x, x + n);
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m[i];
		cout <<search(x, m[i], 0, n -1)<<endl;
	}
	return 0;
}


#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<utility>
#include<vector>
#include<set>
//#include<stack>
//#include <sstream>
//#include<queue>
typedef long long ll;
using namespace std;
const int N = 1e6 + 7;
template<class t>
class queue {
private:
	struct node {
		t item;
		node* next;
	};
	node* front;
	node* rear;
	int length;
public:
	queue() {
		front = rear = NULL;
		length = 0;
	}
	void enqueue(t el) {
		node* newItem = new node;
		newItem->item = el;
		newItem->next = NULL;
		if (isEmpty()) {
			front = rear = newItem;
		}
		else {
			rear->next = newItem;
			rear = newItem;
		}
		length++;
	}
	void dequeue() {
		if (isEmpty()) {
			cout<<"The queue is Empty\n";
		}
		else if(rear == front){
			delete front;
			rear = NULL;
		}
		else {
			node* temp = front;
			front = front->next;
			delete temp;
		}
		length--;
	}

	void print() {
		if (!isEmpty()) {
			cout << "[ ";
			for (node* cur = front; cur != NULL; cur = cur->next) {
				cout << cur->item << " ";
			}
			cout << "]\n";
		}
	}
	bool isEmpty() {
		return rear == NULL;
	}

};
int search(int arr[], int num, int L, int R, bool flag = false) {
	int mid = 0;
	if (R >= L) {
		mid = L + (R - L) / 2;
		if (num == arr[mid])
			return mid + 1;
		else if (num > arr[mid]) {
			return search(arr, num, mid + 1, R, true);
		}
		else {
			return search(arr, num, L, mid - 1, true);
		}

	}
	if (num >= arr[L])
		return L;
	else if (num >= arr[L - 1])
	return L - 1;
	else
		return 0;
}

int n, x[N], q, m[N];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	sort(x, x + n);
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m[i];
		cout <<search(x, m[i], 0, n -1)<<endl;
	}
	return 0;
}


#include <iostream>
using namespace std;
int arr[100005],c ;
int main()
{
    int n; cin>>n;
    for(int i=0 ;i<n ;i++)
    {
        cin>>arr[i];
    }
    int x;cin>>x;
    for(int i=0 ;i<x ;i++)
    {
        int a; cin>>a;
        for(int j=0 ;j<n ;j++)
        {
            if(a>=arr[j])
                c++;
        }
        cout<<c<<endl;
        c=0;

    }

return 0;
}


#include <iostream>
#include<algorithm>
using namespace std;
int arr[100005],c ;
int main()
{
    int n; cin>>n;
    for(int i=0 ;i<n ;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int x;cin>>x;
    for(int i=0 ;i<x ;i++)
    {
        int a; cin>>a;
      cout<<upper_bound(arr ,arr+n ,a)-arr<<endl;

    }

return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	/* #706 (B) */
	int n, q, money;
	cin >> n; //shops

	int *a = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i]; // costs
	}

	cin >> q; // days

	//int *answer = new int[q]; // array of amount of shops that can be used to buy a drink
	vector <int> answer;

	for (int i = 0; i < q; i++) {
		cin >> money;
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (money >= a[j]) {
				count++;
			}
		}
		answer.push_back(count);
	}

	for (int i = 0; i < q; i++) {
		cout << answer[i] << endl;
	}

	//system("pause");
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	/* #706 (B) */
	int n, q, money;
	cin >> n; //shops

	int *a = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i]; // costs
	}

	cin >> q; // days

	int *answer = new int[q]; // array of amount of shops that can be used to buy a drink

	for (int i = 0; i < q; i++) {
		cin >> money;
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (money >= a[j]) {
				count++;
			}
		}
		//answer[i] = count;
		cout << count;
	}

	for (int i = 0; i < q; i++) {
		cout << answer[i] << endl;
	}

	//system("pause");
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	// Use set and binary search instead
	int n, x, q;
	cin >> n >> q;

	int *costs = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs[i] = x;
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (costs[i] > costs[j]) {
				int swap = costs[i];
				costs[i] = costs[j];
				costs[j] = swap;
			}
		}
	}

	for (int i = 0; i < q; i++) {
		cin >> x;
		for (int j = 0; j < n; j++) {
			if (x < costs[j]) {
				cout << j + 1;
				break;
			}
		}
	}

	/*int *costs = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs[i] = x;
	}

	cin >> q;
	int *ans = new int[q];

	for (int i = 0; i < q; i++) {
		cin >> x;
		ans[i] = 0;
		for (int j = 0; j < n; j++) {
			if (x >= costs[j]) ans[i]++;
		}

		printf("%d", ans[i]);

	}*/

	system("pause");
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int n, x, q;
	cin >> n;

	int *costs = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs[i] = x;
	}

	cin >> q;
	int *ans = new int[q];

	for (int i = 0; i < q; i++) {
		cin >> x;
		ans[i] = 0;
		for (int j = 0; j < n; j++) {
			if (x >= costs[j]) ans[i]++;
		}

		printf("%d", ans[i]);
		printf("\n");
	}

	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	/* #706 (B) */
	int n, q, money;
	cin >> n; //shops

	int *a = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i]; // costs
	}

	cin >> q; // days

	//int *answer = new int[q]; // array of amount of shops that can be used to buy a drink
	vector <int> answer;

	for (int i = 0; i < q; i++) {
		cin >> money;
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (money >= a[j]) {
				count++;
			}
		}
		answer.push_back(count);
	}

	for (int i = 0; i < answer.size(); i++) {
		cout << answer[i];
	}

	//system("pause");
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int n, x, q;
	cin >> n >> q;

	int *costs = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs[i] = x;
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (costs[i] > costs[j]) {
				int swap = costs[i];
				costs[i] = costs[j];
				costs[j] = swap;
			}
		}
	}

	for (int i = 0; i < q; i++) {
		cin >> x;
		for (int j = 0; j < n; j++) {
			if (x < costs[j]) {
				cout << j;
				break;
			}
		}
	}

	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	/* #706 (B) */
	int n, q, money;
	cin >> n; //shops

	int *a = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i]; // costs
	}

	cin >> q; // days

	//int *answer = new int[q]; // array of amount of shops that can be used to buy a drink
	vector <int> answer;

	for (int i = 0; i < q; i++) {
		cin >> money;
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (money >= a[j]) {
				count++;
			}
		}
		answer.push_back(count);
	}

	for (int i = 0; i < answer.size(); i++) {
		cout << answer[i] << endl;
	}

	//system("pause");
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	/* #706 (B) */
	int n, q, money;
	cin >> n; //shops

	int *a = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i]; // costs
	}

	cin >> q; // days

	int *answer = new int[q]; // array of amount of shops that can be used to buy a drink

	for (int i = 0; i < q; i++) {
		cin >> money;
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (money >= a[j]) {
				count++;
			}
		}
		answer[i] = count;
	}

	for (int i = 0; i < q; i++) {
		cout << answer[i] << endl;
	}

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;

int main(){

int n, x, q;
	cin >> n;
	vector <int> costs;

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs.push_back(x);
	}

	sort(costs.begin(), costs.end());

	cin >> q;
	vector <int> output(q);

	for (int i = 0; i < q; i++) {
		cin >> x;
		output[i] = binarySearch(costs, x);
	}

	for (int i = 0; i < q; i++) {
		cout << output[i] << " ";

    return 0;
	}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	/* #706 (B) */
	int n, q, money;
	cin >> n; //shops

	int *a = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i]; // costs
	}

	cin >> q; // days

	int *answer = new int[q]; // array of amount of shops that can be used to buy a drink

	for (int i = 0; i < q; i++) {
		cin >> money;
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (money >= a[j]) {
				count++;
			}
		}
		//answer[i] = count;
		cout << count << endl;
	}

	/*
	for (int i = 0; i < q; i++) {
		cout << answer[i] << endl;
	}
	*/

	//system("pause");
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int n, x, q;
	cin >> n;

	int *costs = new int[n];
	int *ans = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs[i] = x;
		ans[i] = 0;
	}

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> x;
		for (int j = 0; j < n; j++) {
			if (x >= costs[j]) ans[j]++;
		}
	}

	for (int i = 0; i < n; i++) cout << ans[i] << endl;

	//cin.get();
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	/* #706 (B) */
	int n, q, money;
	cin >> n; //shops

	//int *a = new int[n];
	vector <int> a;
	a.resize(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i]; // costs
	}

	cin >> q; // days

	//int *answer = new int[q]; // array of amount of shops that can be used to buy a drink
	vector <int> answer;

	for (int i = 0; i < q; i++) {
		cin >> money;
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (money >= a[j]) {
				count++;
			}
		}
		answer.push_back(count);
	}

	for (int i = 0; i < q; i++) {
		cout << answer[i] << endl;
	}

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int binarySearch(vector<int>& prices, int element) {
	int low = 0,
		high = prices.size();

	while (low < high) {
		int mid = (low + high) / 2;

		if (prices[mid] > element) {
			high = mid;
		}
		else if (prices[mid] <= element) {
			low = mid + 1;
		}
	}

	return low;
}

int main(){

int n, x, q;
	cin >> n;
	vector <int> costs;

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs.push_back(x);
	}

	sort(costs.begin(), costs.end());

	cin >> q;
	vector <int> output(q);

	for (int i = 0; i < q; i++) {
		cin >> x;
		output[i] = binarySearch(costs, x);
	}

	for (int i = 0; i < q; i++) {
		cout << output[i] << " ";
	}

    return 0;
}


#include <iostream>

using namespace std;

int main() {
	int n, x, q;
	cin >> n;

	int *costs = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs[i] = x;
	}

	cin >> q;
	int *ans = new int[q];

	for (int i = 0; i < q; i++) {
		cin >> x;
		ans[i] = 0;
		for (int j = 0; j < n; j++) {
			if (x >= costs[j]) ans[i]++;
		}
		cout << ans[i] << endl;
	}

	//for (int i = 0; i < q; i++) cout << ans[i] << endl;

	//cin.get();
	//system("pause");
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int n, x, q;
	cin >> n;

	int *costs = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs[i] = x;
	}

	cin >> q;
	int *ans = new int[q];

	for (int i = 0; i < q; i++) {
		cin >> x;
		ans[i] = 0;
		for (int j = 0; j < n; j++) {
			if (x >= costs[j]) ans[i]++;
		}
	}

	for (int i = 0; i < q; i++) cout << ans[i] << endl;

	//cin.get();
	//system("pause");
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	/* #706 (B) */
	int n, q, money;
	cin >> n; //shops

	int *a = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i]; // costs
	}

	cin >> q; // days

	int *answer = new int[q]; // array of amount of shops that can be used to buy a drink

	for (int i = 0; i < q; i++) {
		cin >> money;
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (money >= a[j]) {
				count++;
			}
		}
		//answer[i] = count;
		cout << count;
	}

	/*
	for (int i = 0; i < q; i++) {
		cout << answer[i] << endl;
	}
	*/

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int binarySearch(vector<int>& prices, int element) {
	int low = 0,
		high = prices.size();

	while (low < high) {
		int mid = (low + high) / 2;

		if (prices[mid] > element) {
			high = mid;
		}
		else if (prices[mid] <= element) {
			low = mid + 1;
		}
	}

	return low;
}

int main(){

int n, x, q;
	cin >> n;
	vector <int> costs;

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs.push_back(x);
	}

	sort(costs.begin(), costs.end());

	cin >> q;
	vector <int> output(q);

	for (int i = 0; i < q; i++) {
		cin >> x;
		output[i] = binarySearch(costs, x);
	}

	for (int i = 0; i < q; i++) {
		cout << output[i] << " ";

    return 0;
	}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	/* #706 (B) */
	int n, q, money;
	cin >> n; //shops

	int *a = new int[n];

	for (int i = 0; i < n; i++) {
		cin >> a[i]; // costs
	}

	cin >> q; // days

	//int *answer = new int[q]; // array of amount of shops that can be used to buy a drink
	vector <int> answer;

	for (int i = 0; i < q; i++) {
		cin >> money;
		int count = 0;
		for (int j = 0; j < n; j++) {
			if (money >= a[j]) {
				count++;
			}
		}
		cout << count;
		//answer.push_back(count);
	}

	/*
	for (int i = 0; i < answer.size(); i++) {
		cout << answer[i];
	}
	*/

	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){

int n, x, q;
	cin >> n;
	vector <int> costs;

	for (int i = 0; i < n; i++) {
		cin >> x;
		costs.push_back(x);
	}

	sort(costs.begin(), costs.end());

	cin >> q;
	vector <int> output(q);

	for (int i = 0; i < q; i++) {
		cin >> x;
		output[i] = binarySearch(costs, x);
	}

	for (int i = 0; i < q; i++) {
		cout << output[i] << " ";

    return 0;
	}


#include <iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n, q, t;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> t;
		cout << upper_bound(x.begin(), x.end(), t) - x.begin() << endl;
	}
}


#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int n, q, count = 0;
	cin >> n;
	int *price = new int[n];
	for(int i = 0; i < n; i++){
	    cin >> price[i];
	}
	cin >> q;
	int *money = new int[q];
	for (int i = 0; i < q; i++) {
	    cin >> money[i];
	}
	sort(price, price + n);
	for (int i = 0; i < q; i++){
	    int l = 0, r = n , m;
	    while (l < r){
	        m = (l + r) / 2;
	        if (price[m] <= money[i]) l = m + 1;
	        else r = m;
	    }
	    cout << r << endl;
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define SIZE 100000

void QuickSort (long int a[], long int left, long int right)
{
	int i = left, j = right, t,  m = a[(right - left + 1) / 2 + left];

	while (i <= j)
	{
		while (a[i] < m)
			i++;

		while (a[j] > m)
			j--;

		if (i <= j)
		{
			t = a[i];
			a[i] = a[j];
			a[j] = t;

			i++;
			j--;
		}
	}

	if (i < right)
		QuickSort (a, i, right);

	if (j > left)
		QuickSort (a, left, j);
}

long int BinarySearch (long int a[], long int n, long int m)
{
	int l = 0, r = n, med = (l + r) / 2;

	while (l <= r)
	{
		med = (l + r)/ 2;
		if (m < a[med])
			r = med - 1;
		else
			l = med + 1;
	}

	return r + 1;
}

void ReadArray (long int a[], long int n)
{
	int i;

	for (i = 0; i < n; i++)
		scanf ("%ld", &a[i]);
}

void WriteArray (long int a[], long int n)
{
	int i;

	for (i = 0; i < n; i++)
		printf ("%ld ", a[i]);

	printf ("\n");
}

int main()
{
	long int n, q, a[SIZE], m[SIZE];

	scanf ("%ld", &n);

	ReadArray (a, n);

	scanf ("%ld", &q);

	ReadArray (m, q);

	QuickSort (a, 0, n - 1);

	{
	long int i;
	for (i = 0; i < q; i++)
		printf ("%ld\n", BinarySearch (a, n - 1, m[i]));
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define SIZE 10000

void QuickSort (long int a[], long int left, long int right)
{
	int i = left, j = right, t,  m = a[(right - left + 1) / 2 + left];

	while (i <= j)
	{
		while (a[i] < m)
			i++;

		while (a[j] > m)
			j--;

		if (i <= j)
		{
			t = a[i];
			a[i] = a[j];
			a[j] = t;

			i++;
			j--;
		}
	}

	if (i < right)
		QuickSort (a, i, right);

	if (j > left)
		QuickSort (a, left, j);
}

long int BinarySearch (long int a[], long int n, long int m)
{
	int l = 0, r = n, med = (l + r) / 2;

	while (l <= r)
	{
		med = (l + r)/ 2;
		if (m < a[med])
			r = med - 1;
		else if (m > a[med])
			l = med + 1;
		else
			return med + 1;
	}

	return r + 1;
}

void ReadArray (long int a[], long int n)
{
	int i;

	for (i = 0; i < n; i++)
		scanf ("%ld", &a[i]);
}

void WriteArray (long int a[], long int n)
{
	int i;

	for (i = 0; i < n; i++)
		printf ("%ld ", a[i]);

	printf ("\n");
}

int main()
{
	long int n, q, a[SIZE], m[SIZE];

	scanf ("%ld", &n);

	ReadArray (a, n);

	scanf ("%ld", &q);

	ReadArray (m, q);

	QuickSort (a, 0, n - 1);

	{
	long int i;
	for (i = 0; i < q; i++)
		printf ("%ld\n", BinarySearch (a, n - 1, m[i]));
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define SIZE 10000

void QuickSort (long int a[], long int left, long int right)
{
	int i = left, j = right, t,  m = a[(right - left + 1) / 2 + left];

	while (i <= j)
	{
		while (a[i] < m)
			i++;

		while (a[j] > m)
			j--;

		if (i <= j)
		{
			t = a[i];
			a[i] = a[j];
			a[j] = t;

			i++;
			j--;
		}
	}

	if (i < right)
		QuickSort (a, i, right);

	if (j > left)
		QuickSort (a, left, j);
}

long int BinarySearch (long int a[], long int n, long int m)
{
	int l = 0, r = n, med = (l + r) / 2;

	while (l <= r)
	{
		med = (l + r)/ 2;
		if (m < a[med])
			r = med - 1;
		else if (m > a[med])
			l = med + 1;
		else
			return med + 1;
	}

	return l;
}

void ReadArray (long int a[], long int n)
{
	int i;

	for (i = 0; i < n; i++)
		scanf ("%ld", &a[i]);
}

void WriteArray (long int a[], long int n)
{
	int i;

	for (i = 0; i < n; i++)
		printf ("%ld ", a[i]);

	printf ("\n");
}

int main()
{
	long int n, q, a[SIZE], m[SIZE];

	scanf ("%ld", &n);

	ReadArray (a, n);

	scanf ("%ld", &q);

	ReadArray (m, q);

	QuickSort (a, 0, n - 1);

	{
	long int i;
	for (i = 0; i < q; i++)
		printf ("%ld\n", BinarySearch (a, n - 1, m[i]));
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

int upper_bound(const std::vector<int>& v, int key)
{
	int st = 0;
	int end = v.size();
	while(st < end)
	{
		int mid = (st + end) / 2;
		if(v[mid] <= key)
			st = mid + 1;
		else
			end = mid;
	}
	return st;
}

int main(){
	//input v1,v2
	int n;
	std::cin>>n;
	std::vector<int> v1(n);
	for(int i=0;i<n;i++){
			std::cin>>v1[i];
	}
	std::sort(v1.begin(), v1.end());
	int q;
	std::cin>>q;
	for(int i=0;i<q;i++){
			int x;
			std::cin>>x;
			std::cout << upper_bound(v1, x) << '\n';
	}
}
//6 3 10 8 6 11 3 4 1 10 3 11


// Interesting Drink.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int binary_search(const vector<int> v, int key)
{
    int first = 0, mid = 0;
    int last = v.size();
    while(first<last)
    {
        mid = (first + last) / 2;
        if (key > v[mid])
            first = mid + 1;
        else if (key < v[mid])
            last = mid;
        else
            return mid+1;
    }
    return -1;
}

int binarySearch(vector <int> v, int first, int last, int search_num)
{
    int middle;
    if (last >= first)
    {
        middle = (first + last) / 2;

        //Checking if the element is present at middle loc
        if (v[middle] == search_num)
        {
            return middle + 1;
        }

        //Checking if the search element is present in greater half
        else if (v[middle] < search_num)
        {
            return binarySearch(v, middle + 1, last, search_num);
        }

        //Checking if the search element is present in lower half
        else
        {
            return binarySearch(v, first, middle - 1, search_num);
        }

    }
    return -1;
}

int main()
{
    vector <int> price;
    vector <int> money;
    int n, q, a;
    cin >> n;

    vector <int>::iterator answer;

    for (int i = 0; i < n; i++)
    {
        cin >> q;
        price.push_back(q);
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a;
        money.push_back(a);
    }

    sort(price.begin(),price.end());

    for (int i = 0; i < q; i++)
    {
        if (money[i] < price[0])
            cout << "0\n";
        else if (money[i] >= price[n - 1])
            cout << n << endl;
        else
        {
            //a = binary_search(price, money[i]);
            answer = upper_bound(price.begin(), price.end(), money[i]);
            cout << answer - price.begin() << endl;
        }

    }

}


// Interesting Drink.cpp : This file contains the 'main' function. Program execution begins and ends there.
// https://codeforces.com/problemset/problem/706/B

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int binary_search(const vector<int> v, int key)
{
    int first = 0, mid = 0;
    int last = v.size();
    while(first<last)
    {
        mid = (first + last) / 2;
        if (key > v[mid])
            first = mid + 1;
        else if (key < v[mid])
            last = mid;
        else
            return mid+1;
    }
    return -1;
}

int main()
{
    vector <int> price;
    vector <int> money;
    int n, q, a;
    cin >> n;

    vector <int>::iterator answer;

    for (int i = 0; i < n; i++)
    {
        cin >> q;
        price.push_back(q);
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a;
        money.push_back(a);
    }

    sort(price.begin(),price.end());

    for (int i = 0; i < q; i++)
    {
        if (money[i] < price[0])
            cout << "0\n";
        else if (money[i] >= price[n - 1])
            cout << n << endl;
        else
        {
            //a = binary_search(price, money[i]);
            answer = upper_bound(price.begin(), price.end(), money[i]);
            cout << answer - price.begin() << endl;
        }

    }

}


// Interesting Drink.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int binary_search(const vector<int> v, int key)
{
    int first = 0, mid = 0;
    int last = v.size();
    while(first<last)
    {
        mid = (first + last) / 2;
        if (key > v[mid])
            first = mid + 1;
        else if (key < v[mid])
            last = mid;
        else
            return mid+1;
    }
    return -1;
}

int binarySearch(vector <int> v, int first, int last, int search_num)
{
    int middle;
    if (last >= first)
    {
        middle = (first + last) / 2;

        //Checking if the element is present at middle loc
        if (v[middle] == search_num)
        {
            return middle + 1;
        }

        //Checking if the search element is present in greater half
        else if (v[middle] < search_num)
        {
            return binarySearch(v, middle + 1, last, search_num);
        }

        //Checking if the search element is present in lower half
        else
        {
            return binarySearch(v, first, middle - 1, search_num);
        }

    }
    return -1;
}

int main()
{
    vector <int> price;
    vector <int> money;
    int n, q, a;
    cin >> n;

    vector <int>::iterator answer;

    for (int i = 0; i < n; i++)
    {
        cin >> q;
        price.push_back(q);
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a;
        money.push_back(a);
    }

    sort(price.begin(),price.end());

    for (int i = 0; i < q; i++)
    {
        if (money[i] < price[0])
            cout << "0\n";
        else if (money[i] >= price[n - 1])
            cout << n << endl;
        else
        {
            //a = binary_search(price, money[i]);
            answer = upper_bound(price.begin(), price.end(), a);
            cout << answer - price.begin() << endl;
        }

    }

}


// Interesting Drink.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int binary_search(const vector<int> v, int key)
{
    int first = 0, mid = 0;
    int last = v.size();
    while(first<last)
    {
        mid = (first + last) / 2;
        if (key > v[mid])
            first = mid + 1;
        else if (key < v[mid])
            last = mid;
        else
            return mid+1;
    }
    return -1;
}

int binarySearch(vector <int> v, int first, int last, int search_num)
{
    int middle;
    if (last >= first)
    {
        middle = (first + last) / 2;

        //Checking if the element is present at middle loc
        if (v[middle] == search_num)
        {
            return middle + 1;
        }

        //Checking if the search element is present in greater half
        else if (v[middle] < search_num)
        {
            return binarySearch(v, middle + 1, last, search_num);
        }

        //Checking if the search element is present in lower half
        else
        {
            return binarySearch(v, first, middle - 1, search_num);
        }

    }
    return -1;
}

int main()
{
    vector <int> price;
    vector <int> money;
    int n, q, a;
    cin >> n;

    vector <int>::iterator answer;

    for (int i = 0; i < n; i++)
    {
        cin >> q;
        price.push_back(q);
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a;
        money.push_back(a);
    }

    sort(price.begin(),price.end());

    for (int i = 0; i < q; i++)
    {
        if (money[i] < price[0])
            cout << "0\n";
        else if (money[i] >= price[n - 1])
            cout << n << endl;
        else
        {
            a = binary_search(price, money[i]);
            answer = upper_bound(price.begin(), price.end(), money[i]);
            cout << answer - price.begin() << endl;
        }

    }

}


// Interesting Drink.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int binary_search(const vector<int> v, int key)
{
    int first = 0, mid = 0;
    int last = v.size();
    while(first<last)
    {
        mid = (first + last) / 2;
        if (key > v[mid])
            first = mid + 1;
        else if (key < v[mid])
            last = mid;
        else
            return mid+1;
    }
    return -1;
}

int main()
{
    vector <int> price;
    vector <int> money;
    int n, q, a;
    cin >> n;

    vector <int>::iterator answer;

    for (int i = 0; i < n; i++)
    {
        cin >> q;
        price.push_back(q);
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a;
        money.push_back(a);
    }

    sort(price.begin(),price.end());

    for (int i = 0; i < q; i++)
    {
        if (money[i] < price[0])
            cout << "0\n";
        else if (money[i] >= price[n - 1])
            cout << n << endl;
        else
        {
            //a = binary_search(price, money[i]);
            answer = upper_bound(price.begin(), price.end(), a);
            cout << answer - price.begin() << endl;
        }

    }

}


// Interesting Drink.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int binary_search(const vector<int> v, int key)
{
    int first = 0, mid = 0;
    int last = v.size();
    while(first<last)
    {
        mid = (first + last) / 2;
        if (key > v[mid])
            first = mid + 1;
        else if (key < v[mid])
            last = mid;
        else
            return mid+1;
    }
    return -1;
}

int binarySearch(vector <int> v, int first, int last, int search_num)
{
    int middle;
    if (last >= first)
    {
        middle = (first + last) / 2;

        //Checking if the element is present at middle loc
        if (v[middle] == search_num)
        {
            return middle + 1;
        }

        //Checking if the search element is present in greater half
        else if (v[middle] < search_num)
        {
            return binarySearch(v, middle + 1, last, search_num);
        }

        //Checking if the search element is present in lower half
        else
        {
            return binarySearch(v, first, middle - 1, search_num);
        }

    }
    return -1;
}

int main()
{
    vector <int> price;
    vector <int> money;
    int n, q, a;
    cin >> n;

    vector <int>::iterator answer;

    for (int i = 0; i < n; i++)
    {
        cin >> q;
        price.push_back(q);
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a;
        money.push_back(a);
    }

    sort(price.begin(),price.end());

    for (int i = 0; i < q; i++)
    {
        if (money[i] < price[0])
            cout << "0\n";
        else if (money[i] >= price[n - 1])
            cout << n << endl;
        else
        {
            a = binary_search(price, money[i]);
            answer = upper_bound(price.begin(), price.end(), a);
            cout << a << endl;
        }

    }

}


// Interesting Drink.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int binary_search(const vector<int> v, int key)
{
    int first = 0, mid = 0;
    int last = v.size();
    while(first<last)
    {
        mid = (first + last) / 2;
        if (key > v[mid])
            first = mid + 1;
        else if (key < v[mid])
            last = mid;
        else
            return mid+1;
    }
    return -1;
}

int main()
{
    vector <int> price;
    vector <int> money;
    int n, q, a;
    cin >> n;

    vector <int>::iterator answer;

    for (int i = 0; i < n; i++)
    {
        cin >> q;
        price.push_back(q);
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a;
        money.push_back(a);
    }

    sort(price.begin(),price.end());

    for (int i = 0; i < q; i++)
    {
        if (money[i] < price[0])
            cout << "0\n";
        else if (money[i] >= price[n - 1])
            cout << n << endl;
        else
        {
            //a = binary_search(price, money[i]);
            answer = upper_bound(price.begin(), price.end(), money[i]);
            cout << answer - price.begin() << endl;
        }

    }

}


// Interesting Drink.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int binary_search(const vector<int> v, int key)
{
    int first = 0, mid = 0;
    int last = v.size();
    while(first<last)
    {
        mid = (first + last) / 2;
        if (key > v[mid])
            first = mid + 1;
        else if (key < v[mid])
            last = mid;
        else
            return mid+1;
    }
    return -1;
}

int main()
{
    vector <int> price;
    vector <int> money;
    int n, q, a;
    cin >> n;

    vector <int>::iterator answer;

    for (int i = 0; i < n; i++)
    {
        cin >> q;
        price.push_back(q);
    }
    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a;
        money.push_back(a);
    }

    sort(price.begin(),price.end());

    for (int i = 0; i < q; i++)
    {
        //if (money[i] < price[0])
       //     cout << "0\n";
       // else if (money[i] >= price[n - 1])
       //     cout << n << endl;
       // else
       // {
            //a = binary_search(price, money[i]);
            answer = upper_bound(price.begin(), price.end(), money[i]);
            cout << answer - price.begin() << endl;
       // }

    }

}


#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

using type = int;
using line = vector <type>;

const type INF = 0x3f3f3f3f;

int main() {
	// ...
	ios::sync_with_stdio(false);
	//freopen("input.txt", "rt", stdin);
	int n;
	cin >> n;

	line d(n);
	for (auto& i : d)
		cin >> i;

	sort(d.begin(), d.end());

	int m;
	cin >> m;

	while (m) {
		int f;
		cin >> f;

		int l(0), r(n - 1), ans(0);
		while (l <= r) {
			int m = (l + r) / 2;

			if (d[m] <= f) {
				ans = m + 1;
				l = m + 1;
			}
			else {
				r = m - 1;
			}
		}

		cout << ans << "\n";

		--m;
	}

	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

int a[2222], b[2222];
int A,B;
double dp[2222][2222];

int main(){
	int n,m;
	cin>>n>>m;
	REP(i,m){
		int x,y;
		scanf("%d%d", &x, &y);
		a[x]=1;
		b[y]=1;
	}
	REP(i,n+1){
		A+=a[i];
		B+=b[i];
	}
	dp[n][n]=0.0;
	for(int i=n; i>=A; i--){
		for(int j=n; j>=B; j--){
			if(i==j && i==n)continue;
			dp[i][j]=n*n*1.0/(n*n*1.0-i*j);
			if(i+1<=n)dp[i][j]+=(n*1.0-i)*j/(n*n*1.0-i*j)*dp[i+1][j];
			if(j+1<=n)dp[i][j]+=(n*1.0-j)*i/(n*n*1.0-i*j)*dp[i][j+1];
			if(i+1<=n && j+1<=n)dp[i][j]+=(n*1.0-i)*(n*1.0-j)/(n*n*1.0-i*j)*dp[i+1][j+1];
		}
	}
	printf("%.10f\n", dp[A][B]);
	return 0;
}


#pragma comment(linker,"/stack:256000000")

#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <cstdio>
#include <cfloat>
#include <cassert>

using namespace std;

#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()

const int N = 2014;

double dp[N][N];
bool urow[N], ucol[N];

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m, row, col;
	scanf("%d %d", &n, &m);
	REP(i, m) {
		scanf("%d %d", &row, &col);
		--row, --col;
		urow[row] = 1;
		ucol[col] = 1;
	}
	for (int r = n; r >= 0; r--) {
		for (int c = n; c >= 0; c--) {
			if (r == n && c == n) {
				dp[r][c] = 0;
			} else {
				dp[r][c] = (1.0 / ((1 - (1.0 * r * c) / (1.0 * n * n)))) * ((1.0 * r * c) / (1.0 * n * n) + (1.0 * n * n - ((r + c) * n - r * c)) / (1.0 * n * n) * (1 + dp[r + 1][c + 1])
							+ (r * n - r * c) / (1.0 * n * n) * (1 + dp[r][c + 1]) + (c * n - c * r) / (1.0 * n * n) * (1 + dp[r + 1][c]));
			}
		}
	}
	int rows = 0, cols = 0;
	REP(i, n) if (urow[i]) ++rows;
	REP(i, n) if (ucol[i]) ++cols;
	printf("%.10lf\n", dp[rows][cols]);
	return 0;
}


#include <cstdio>
#include <cstring>

const int N = 2010;
int n, m, r, c, row[N], col[N];
double dp[N][N];

void Init() {
	memset(dp, 0, sizeof(dp));
	memset(row, -1, sizeof(row));
	memset(col, -1, sizeof(col));
}

void GetData() {
	int a, b;
	scanf("%d%d", &n, &m);
	while(m--) {
		scanf("%d%d", &a, &b);
		row[a] = col[b] = 0;
	}
}

void Solve() {
	int i, j;
	double s;
	r = c = 0;
	for(i = 1; i <= n; ++i) r -= row[i];
	for(i = 1; i <= n; ++i) c -= col[i];
	for(i = 0; i <= r; ++i) {
		for(j = 0; j <= c; ++j) {
			if(i == 0 && j == 0) continue;
			s = 1.0;
			if(i != 0) s += dp[i - 1][j] * i * (n - j) / n / n;
			if(j != 0) s += dp[i][j - 1] * (n - i) * j / n / n;
			if(i != 0 && j != 0) s += dp[i - 1][j - 1] * i * j / n / n;
			dp[i][j] = s / (1.0 - (double)(n - i) * (n - j) / n / n);
		}
	}
	printf("%lf\n", dp[r][c]);
}

int main() {
	Init();
	GetData();
	Solve();
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <bitset>
#include <ctime>
#include <cmath>
#include <cassert>
#include <algorithm>
using namespace std;

typedef long long ll;
const int size = 2007;
const ll modulo = 1000000007;
const ll INF = 1e18;
const double EPS = 1e-6;

int painted[size][size];
double dp[size][size];

int main()
{
	cin.sync_with_stdio(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif
	int n, m;
	cin >> n >> m;
	while (m--)
	{
		int x, y;
		cin >> x >> y;
		--x; --y;
		painted[x][y] = 1;
	}
	int rows = 0, columns = 0;
	for (int i = 0; i < n; i++)
	{
		bool empty = true;
		for (int j = 0; j < n && empty; j++)
		if (painted[i][j])
			empty = false;
		if (empty) ++rows;
	}
	for (int j = 0; j < n; j++)
	{
		bool empty = true;
		for (int i = 0; i < n && empty; i++)
		if (painted[i][j])
			empty = false;
		if (empty) ++columns;
	}
	dp[0][0] = 0;
	for (int r = 1; r <= rows; r++)
		dp[r][0] = double(n) / r + dp[r - 1][0];
	for (int c = 1; c <= columns; c++)
		dp[0][c] = double(n) / c + dp[0][c-1];
	for (int r = 1; r <= rows; r++)
	for (int c = 1; c <= columns; c++)
	{
		double znam = double(n) * (r + c) - double(r)*c;
		dp[r][c] = double(n)* n / znam + dp[r - 1][c - 1] * r * c / znam
			+ dp[r - 1][c] * r * (n-c) / znam + dp[r][c - 1] * c * (n-r) / znam;
	}
	printf("%.9f\n", dp[rows][columns]);
	return 0;
}


#include <iostream>
#include <iomanip>
using namespace std;

int n, m, t_emptyrow, t_emptycol;
bool occupied_row[2001], occupied_col[2001];
double f[2001][2001];

int main(){
	cin >> n >> m;
	t_emptyrow = t_emptycol = n;
	for (int i = 0; i < m; i++){
		int r, c;
		cin >> r >> c;
		if (!occupied_row[r]){
			occupied_row[r] = true; t_emptyrow--;
		}
		if (!occupied_col[c]){
			occupied_col[c] = true; t_emptycol--;
		}
	}
	//(in+jn-ij) f[i][j]= i*j*f[i-1][j-1] + i*(n-j)*f[i-1][j] + (n-i)*j*f[i][j-1] + n^2

	for (int i = 1; i <= n; i++) f[i][0] = f[0][i] = f[0][i - 1] + double (n) / double(i);
	for (int i = 1; i <= t_emptyrow; i++)
		for (int j = 1; j <= t_emptycol; j++)
			f[i][j] = (i*j*f[i-1][j-1] + i*(n-j)*f[i-1][j] + (n-i)*j*f[i][j-1] + n*n) / (i*n+j*n-i*j);
	cout << setprecision(13) << f[t_emptyrow][t_emptycol];
}


#define _CRT_SECURE_NO_WARNINGS

#pragma comment (linker, "/STACK:1000000000")

#include <iostream>
#include <ctime>
#include <string>
#include <vector>
#include <set>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <complex>
#include <hash_map>
#include <hash_set>

using namespace std;

#define pb push_back
#define pob pop_back
#define rs resize
#define as assign
#define fs first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define mp make_pair
#define sz(a) (int)a.size()
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FOD(i, n) for (int i = n - 1; i >= 0; --i)

typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <ll> vl;
typedef vector <vl> vvl;
typedef vector <bool> vb;
typedef vector <vb> vvb;
typedef vector <string> vs;
typedef vector <vs> vvs;
typedef vector <char> vc;
typedef vector <vc> vvc;
typedef vector <vvc> vvvc;
typedef vector <vvi> vvvi;
typedef vector <vvvi> vvvvi;
typedef vector <vvl> vvvl;
typedef vector <vvvl> vvvvl;
typedef vector <vvb> vvvb;
typedef double db;
typedef long double ldb;
typedef vector <db> vdb;
typedef vector <vdb> vvdb;
typedef vector <vvdb> vvvdb;
typedef vector <ldb> vldb;
typedef pair <int, int> ii;
typedef pair <int, char> ic;
typedef pair <ll, ll> lll;
typedef pair <int, ll> il;
typedef pair <ll, int> li;
typedef vector <ii> vii;
typedef vector <ic> vic;
typedef vector <vic> vvic;
typedef vector <vii> vvii;
typedef vector <lll> vll;
typedef vector <vll> vvll;
typedef set <int> si;
typedef set <ll> sl;
typedef set <pair <ll, int> > sli;
typedef set <pair <ll, ll> > sll;
typedef set <ii> sii;
typedef set <pair <int, bool> > sib;
typedef vector <si> vsi;
typedef vector <sii> vsii;
typedef map <int, int> mii;
typedef map <string, char> msc;
typedef map <char, int> mci;
typedef queue <int> qi;
typedef deque <int> di;
typedef stack <int> sti;

const ll inf = (ll)1e9 + 7;
const ldb eps = 1e-18;
const int M = 500;
const int N = 100000;

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int s = n, t = n;
    vb ux(n, 0);
    vb uy(n, 0);
    for (int i = 0; i < m; ++i)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        --x; --y;
        if (!ux[x])
            --s;
        if (!uy[y])
            --t;
        ux[x] = 1;
        uy[y] = 1;
    }
    vvdb dp(n + 1, vdb(n + 1, 0.0));
    for (int i = 0; i <= s; ++i)
        for (int j = 0; j <= t; ++j)
        {
            if (i == 0 && j == 0)
                continue;
            if (i == 0)
                dp[0][j] = dp[0][j - 1] + db(n) / j;
            if (j == 0)
                dp[i][0] = dp[i - 1][0] + db(n) / i;
            if (i == 0 || j == 0)
                continue;
            dp[i][j] = 1.0 + (dp[i - 1][j - 1] * i * j + dp[i - 1][j] * (n - j) * i + dp[i][j - 1] * (n - i) * j) / db(n * n);
            dp[i][j] /= (1. - (n - i) * (n - j) / db(n * n));
        }
    printf("%.6lf", dp[s][t]);
    return 0;
}


    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <memory.h>
    #include <math.h>
    #include <assert.h>
    #include <stack>
    #include <queue>
    #include <map>
    #include <set>
    #include <algorithm>
    #include <string>
    #include <functional>
    #include <vector>
    #include <deque>
    #include <utility>
    #include <bitset>
    #include <limits.h>

    using namespace std;
    typedef long long ll;
    typedef double lf;
    typedef long double llf;
    typedef unsigned long long llu;

    int N, M;
    lf Table[2005][2005];
    int R, C;
    bool chkR[2005], chkC[2005];

    int main() {
    	scanf("%d%d", &N, &M);

    	R = C = N;
    	for(int i = 1; i <= M; i++) {
    		int r, c; scanf("%d%d", &r, &c);
    		if(!chkR[r]) --R;
    		if(!chkC[c]) --C;
    		chkR[r] = chkC[c] = true;
    	}

    	for(int i = 1; i <= N; i++) Table[i][0] = Table[i-1][0] + (lf)N / i;
    	for(int j = 1; j <= N; j++) Table[0][j] = Table[0][j-1] + (lf)N / j;
    	for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++) {
    		lf &v = Table[i][j];
    		v = (i * j * Table[i-1][j-1])
    			 + ((N - i) * j * Table[i][j-1])
    			 + (i * (N - j) * Table[i-1][j]);
    		v /= N*N;
    		v = v+1;
    		v /= (1. - (lf)(N-i) * (N-j) / (N*N));
    	}

    	printf("%.10Lf\n", Table[R][C]);
    	return 0;
    }


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int>> vvi;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()

#define pb push_back

int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "rt", stdin);
  freopen("output.txt", "wt", stdout);
#endif

  int n,m,k;
//int ans=0;
  //cin >> a >> k;
  k=0;
cin>>n>>m;

std::vector<double> p((n+1)*(n+1),0);
for(int i=1;i<=n;i++){
    int u=n-i;
    double pi=(double)i/(double) n;
    double pu=(double)u/(double) n;
    double x=(1.+pi*p[i-1])/(1.-pu);
    p[i]=x;
    p[(n+1)*i]=x;

}
for(int i=1;i<=n;i++){
    for(int j=1; j<=n; j++){
        int u=n-i;
        int v=n-j;
        double pi=(double)i/(double) n;
        double pj=(double)j/(double) n;
        double pu=(double)u/(double) n;
        double pv=(double)v/(double) n;
        p[i*(n+1)+j]=(1.+pi*pv*p[(i-1)*(n+1)+j]+pu*pj*p[i*(n+1)+j-1]+pi*pj*p[(i-1)*(n+1)+j-1])/(1.-pu*pv);
    }

}

vi c(n+1,false);
vi r(n+1, false);
for(int i=0; i<m; i++){
    int a,b;
    cin>>a>>b;
    c[a]=true;
    r[b]=true;
}

int cp=0, rp=0;
for(int i=1;i<=n;i++){
    if(c[i]) cp++;
    if(r[i]) rp++;
}
int cup=n-cp;
int rup=n-rp;
printf("%.8f",p[cup*(n+1)+rup]);

  return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
const int NMAX = 2222;
int n,m;
double dp[NMAX][NMAX];

bool row[NMAX],col[NMAX];

double back(int r,int c){
	// r, c already painted

	double& ret = dp[r][c];
	if(ret>=0) return ret;

	if(r==n && c==n) return ret=0;
	if(r>n || c>n) return ret=0;

	double px,pr,pc,pa;
	px = r/(double)n * c/(double)n;
	pr = r/(double)n - px;
	pc = c/(double)n - px;
	pa = 1-px-pr-pc;

	double _r = back(r,c+1), _c = back(r+1,c), _a = back(r+1,c+1);
	/*
	ret = 1 + px ret + pr _r + pc _c + pa _a
	(1-px)ret = 1+pr_r+pc_c+pa_a
	*/
	return ret = (1+pr*_r+pc*_c+pa*_a)/(1-px);
}

int main(){
	cin.sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		row[x] = true; col[y] = true;
	}

	for(int i=0;i<2222;i++)for(int j=0;j<2222;j++)dp[i][j] = -1.;

	int r,c;
	r = count(row+1,row+1+n,true); c = count(col+1,col+1+n,true);
	cout.precision(10);
	cout<<back(r,c);
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cmath>
#define Inf (1<<29)
#define eps 1e-8
#define N 2050
using namespace std;
double d[N][N];
bool r[N],c[N];
int main()
{
	int x,y,n,m,j,i,cntr,cntc;
	memset(r,0,sizeof(r));
	memset(c,0,sizeof(c));
	memset(d,0,sizeof(d));
	scanf("%d%d",&n,&m);
	cntr=cntc=n;
	while(m--)
	{
		scanf("%d%d",&x,&y);
		if(!r[x])cntr--;
		if(!c[y])cntc--;
		r[x]=c[y]=true;
	}
	d[0][0]=0;
	for(i=1;i<=n;i++)
		d[i][0]=d[i-1][0]+n*1.0/i;
	for(i=1;i<=n;i++)
		d[0][i]=d[0][i-1]+n*1.0/i;
	for(i=1;i<=cntr;i++)
	{
		for(j=1;j<=cntc;j++)
		{
			d[i][j]=n*n;
			d[i][j]+=i*j*d[i-1][j-1];
			d[i][j]+=i*(n-j)*d[i-1][j];
			d[i][j]+=(n-i)*j*d[i][j-1];
			d[i][j]/=(n*n-(n-i)*(n-j));

		}
	}
	printf("%.10lf\n",d[cntr][cntc]);
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <vector>
#include <complex>
#include <deque>
#include <queue>

using namespace std;

#define sz(x) (int)((x).size())

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double pi = acos(-1.0);
const double eps = 1e-9;

template<class t> inline t sqr(t x) { return x * x; }

inline int getBit(int x, int pos) {
	return ((x >> pos) & 1);
}

const int maxn = (int)(2e3) + 10;

int n, m, R, C;
double dp[maxn][maxn];
bool used[2][maxn];

int main() {

	scanf("%d%d", &n, &m);
	R = n;
	C = n;
	while (m--) {
		int r, c;
		scanf("%d%d", &r, &c);
		--r;
		--c;
		if (!used[0][r])
			R--;
		if (!used[1][c])
			C--;
		used[0][r] = used[1][c] = true;
	}
	dp[0][0] = 0.0;
	for (int i = 1; i < n + 1; i++) {
		dp[i][0] = dp[i - 1][0] + (n + 0.0) / i;
		dp[0][i] = dp[0][i - 1] + (n + 0.0) / i;
	}

	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < n + 1; j++) {
			dp[i][j] = (dp[i - 1][j - 1] * i * j + dp[i - 1][j] * i * (n - j) + dp[i][j - 1] * (n - i) * j + (n + 0.0) * (n + 0.0)) / ((n + 0.0) * (n + 0.0) - (n - i + 0.0) * (n - j + 0.0));
		}
	}
	printf("%.12lf\n", dp[R][C]);

	return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

#define Mod 1000000007
//int a,b,ans=0;
//char s[200002];
//int main()
//{
//	cin>>a>>b;
//	if(!a)
//	{
//		ans-=b*b;
//		for(int i=0;i<b;i++)
//			s[i]='x';
//	}
//	else if(!b)
//	{
//		ans=a*a;
//		for(int i=0;i<a;i++)
//			s[i]='o';
//	}
//	else if(a<b)
//	{
//		int c=b/(a+1);
//		int d=b%(a+1);
//		int tmp=0;
//		for(int i=1;i<=d;i++)
//		{
//			ans-=(c+1)*(c+1);
//			for(int j=0;j<c+1;j++)
//				s[tmp++]='x';
//			s[tmp++]='o';
//		}
//		for(int i=d+1;i<=a+1;i++)
//		{
//			ans-=c*c;
//			for(int j=0;j<c;j++)
//				s[tmp++]='x';
//			if(i!=a+1)
//				s[tmp++]='o';
//		}
//		ans+=a;
//	}
//	else
//	{
//		for(int i=0;i<b/2;i++)
//			s[i]='x';
//		for(int i=0;i<a;i++)
//			s[i+b/2]='o';
//		for(int i=0;i<(b+1)/2;i++)
//			s[i+b/2+a]='x';
//		ans=a*a-(b/2)*(b/2)-((b+1)/2)*((b+1)/2);
//	}
//	cout<<ans<<endl<<s<<endl;
//	return 0;
//}

int n,m,r,c,x[2001],y[2001],a,b;
double f[2001][2001];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	r=c=n;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		if(!x[a]) r--;
		if(!y[b]) c--;
		x[a]=1,y[b]=1;
	}
	f[0][0]=0;
	for(int i=1;i<=n;i++)
	{
		f[i][0]=f[i-1][0]+(double)n/i;
		f[0][i]=f[0][i-1]+(double)n/i;
	}
	for(int i=1;i<=r;i++)
		for(int j=1;j<=c;j++)
		{
			f[i][j]=(f[i-1][j-1]*i*j+f[i][j-1]*j*(n-i)+f[i-1][j]*i*(n-j)+n*n)/(n*n-(n-i)*(n-j));
		}
	cout<<f[r][c]<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

int n, m;
bool checkR[1010], checkC[1010];
double expected[1010][1010];

int main() {

	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int r, c;
		scanf("%d%d", &r, &c);
		checkR[r] = 1;
		checkC[c] = 1;
	}

	int countR = 0, countC = 0;
	for(int i = 1; i <= n; i++) {
		countR += !checkR[i];
		countC += !checkC[i];
	}

	for(int i = 1; i <= n; i++)
		expected[i][0] = (1 + expected[i-1][0] * double(i)/n)/(double(i)/n);
	for(int j = 1; j <= n; j++)
		expected[0][j] = (1 + expected[0][j-1] * double(j)/n)/(double(j)/n);

	for(int i = 1; i <= countR; i++)
		for(int j = 1; j <= countC; j++)
			expected[i][j] = (1 + expected[i-1][j]*i*(n-j)/double(n*n)
								+ expected[i][j-1]*(n-i)*j/double(n*n)
								+ expected[i-1][j-1]*i*j/double(n*n)) / (1 - (n-i)*(n-j)/double(n*n));

	printf("%.6lf", expected[countR][countC]);

	return 0;
}


#include <cstdio>
#include <iostream>

using namespace std;

int n, m;
bool checkR[2010], checkC[2010];
double expected[2010][2010];

int main() {

    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++) {
        int r, c;
        scanf("%d%d", &r, &c);
        checkR[r] = 1;
        checkC[c] = 1;
    }

    int countR = 0, countC = 0;
    for(int i = 1; i <= n; i++) {
        countR += !checkR[i];
        countC += !checkC[i];
    }

    for(int i = 1; i <= n; i++)
        expected[i][0] = (1 + expected[i-1][0] * double(i)/n)/(double(i)/n);
    for(int j = 1; j <= n; j++)
        expected[0][j] = (1 + expected[0][j-1] * double(j)/n)/(double(j)/n);

    for(int i = 1; i <= countR; i++)
        for(int j = 1; j <= countC; j++)
            expected[i][j] = (1 + expected[i-1][j]*i*(n-j)/double(n*n)
                                + expected[i][j-1]*(n-i)*j/double(n*n)
                                + expected[i-1][j-1]*i*j/double(n*n)) / (1 - (n-i)*(n-j)/double(n*n));

    printf("%.6lf", expected[countR][countC]);

    return 0;
}


#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;

int n, m;
int f[2020][2020];
bool R[2020], C[2020];
deque<pair<int, int>> qu;
deque<int> step;
double prob[2][5050][5050];

int main() {

    scanf("%d%d", &n, &m);
    for(int i = 1; i <= m; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        R[x] = 1;
        C[y] = 1;
    }

    int crow = 0, ccol = 0;
    for(int i = 1; i <= n; i++) {
        crow += R[i];
        ccol += C[i];
    }

    double ret = 0;
    qu.push_back(make_pair(crow, ccol));
    step.push_back(0);
    prob[0][crow][ccol] = 1;
    while (!qu.empty()) {
        pair<int, int> now = qu.front(); qu.pop_front();
        int cstep = step.front(); step.pop_front();
        double pr = prob[cstep&1][now.first][now.second];
        prob[cstep&1][now.first][now.second] = 0;
        if (cstep && pr*cstep < 1e-6) continue;
        if (now == make_pair(n, n)) {
            ret += pr*cstep;
            continue;
        }

        if (prob[1^(cstep&1)][now.first][now.second] < 1e-8) {
            qu.push_back(now);
            step.push_back(cstep+1);
        }
        prob[1^(cstep&1)][now.first][now.second] += pr*(now.first*now.second+0.0)/(n*n);

        if (prob[1^(cstep&1)][now.first+1][now.second] < 1e-8) {
            qu.push_back(make_pair(now.first+1, now.second));
            step.push_back(cstep+1);
        }
        prob[1^(cstep&1)][now.first+1][now.second] += pr*((n-now.first)*now.second+0.0)/(n*n);

        if (prob[1^(cstep&1)][now.first][now.second+1] < 1e-8) {
            qu.push_back(make_pair(now.first, now.second+1));
            step.push_back(cstep+1);
        }
        prob[1^(cstep&1)][now.first][now.second+1] += pr*(now.first*(n-now.second)+0.0)/(n*n);

        if (prob[1^(cstep&1)][now.first+1][now.second+1] < 1e-8) {
            qu.push_back(make_pair(now.first+1, now.second+1));
            step.push_back(cstep+1);
        }
        prob[1^(cstep&1)][now.first+1][now.second+1] += pr*((n-now.first)*(n-now.second)+0.0)/(n*n);
    }

    printf("%.4f", ret);

    return 0;
}


#include<iostream>
#include<cstdio>
#include<list>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<cmath>
#include<memory.h>
#include<set>
#include<cctype>

#define ll long long

#define eps 1e-8

const int inf = 1<<30;

const ll INF = 1ll<<61;

using namespace std;

//vector<pair<int,int> > G;
//typedef pair<int,int > P;
//vector<pair<int,int> > ::iterator iter;
//
//map<ll,int >mp;
//map<ll,int >::iterator p;

int n,m;

int xx[20000 + 55],yy[20000 + 55];

double dp[2000 + 55][2000 + 55];

int cntx = 0,cnty = 0;

void init() {
	memset(xx,0,sizeof(xx));
	memset(yy,0,sizeof(yy));
	memset(dp,0.00,sizeof(dp));
}

bool input() {
	while(cin>>n>>m) {
		cntx = cnty = n;
		for(int i=0;i<m;i++) {
			int x,y;
			scanf("%d %d",&x,&y);
			if(!xx[x])cntx--;
			if(!yy[y])cnty--;
			xx[x]++;
			yy[y]++;
		}
		return false;
	}
	return true;
}

void cal() {
	dp[0][0] = 0.00;
	for(int i=1;i<=n;i++) {
		dp[i][0] = dp[i - 1][0] + n * 1.0/i;
		dp[0][i] = dp[0][i - 1] + n * 1.0/i;
	}
	for(int i=1;i<=cntx;i++) {
		for(int j=1;j<=cnty;j++) {
			dp[i][j] += n * n * 1.0;
			dp[i][j] += i * j * dp[i - 1][j - 1];
			dp[i][j] += (n - i) * j * dp[i][j - 1];
			dp[i][j] += i * (n - j) * dp[i - 1][j];
			dp[i][j] /= (n * n - (n - i) * (n - j));
		}
	}
	printf("%.10lf\n",dp[cntx][cnty]);
}

void output() {

}

int main() {
	while(true) {
		init();
		if(input())return 0;
		cal();
		output();
	}
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>

using namespace::std;

int n1,m,x,y;
bool cx[2003];
bool cy[2003];
double d[2003][2003];

int main(){
    scanf("%d %d",&n1,&m);
    for(int i=0;i<m;i++){
        int in1,in2;
        scanf("%d %d",&in1,&in2);
        if(!cx[in1]) cx[in1]=true,x++;
        if(!cy[in2]) cy[in2]=true,y++;
    }
    x=n1-x,y=n1-y;
    double n=n1;
    for(int i=0;i<=x;i++)
        for(int j=0;j<=y;j++){
                double sum=(n-i)*(n-j)/(n*n);
                if(i!=0) sum+=i*(n-j)/(n*n)*(d[i-1][j]+1);
                if(j!=0) sum+=(n-i)*j/(n*n)*(d[i][j-1]+1);
                if(i!=0 && j!=0) sum+=i*j/(n*n)*(d[i-1][j-1]+1);
                if(i!=0 || j!=0) d[i][j]=(sum/(1-(n-i)*(n-j)/(n*n)));
            }
    printf("%lf",d[x][y]);
    return 0;
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	n, m   int
	br, bc int
	f      [][]float64
)

func foo(x, y int) (ret float64) {
	if f[x][y] > -1.0 {
		return f[x][y]
	}

	defer func() {
		f[x][y] = ret
	}()

	if x == 0 {
		for i := y; i >= 1; i-- {
			ret += float64(n) / float64(i)
		}
		return
	}

	if y == 0 {
		for i := x; i >= 1; i-- {
			ret += float64(n) / float64(i)
		}
		return
	}

	nn := float64(n * n)

	p1 := (float64(x*y) / nn)
	e1 := foo(x-1, y-1) * p1

	p2 := float64((n-y)*x) / nn
	e2 := foo(x-1, y) * p2

	p3 := float64((n-x)*y) / nn
	e3 := foo(x, y-1) * p3

	ret = (e1 + e2 + e3 + 1) / (p1 + p2 + p3)
	return
}

func main() {
	fmt.Fscan(reader, &n, &m)

	f = make([][]float64, n+1)
	for i := 0; i < len(f); i++ {
		f[i] = make([]float64, n+1)
		for j := 0; j < len(f[i]); j++ {
			f[i][j] = -10.0
		}
	}

	rmap := map[int]bool{}
	cmap := map[int]bool{}

	for i := 0; i < m; i++ {
		var r, c int
		fmt.Fscan(reader, &r, &c)
		rmap[r] = true
		cmap[c] = true
	}

	ans := foo(n-len(rmap), n-len(cmap))
	fmt.Printf("%.10f\n", ans)
}


package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

var expect, prob [2002][2002]float64

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	row := make([]bool, n+1)
	col := make([]bool, n+1)
	var rowCount, colCount int
	for i := 0; i < m; i++ {
		var r, c int
		fmt.Fscanf(reader, "%d %d\n", &r, &c)
		if !row[r] {
			rowCount++
			row[r] = true
		}
		if !col[c] {
			colCount++
			col[c] = true
		}
	}
	prob[rowCount][colCount] = 1.0
	for i := rowCount; i <= n; i++ {
		for j := colCount; j <= n; j++ {
			p := float64(i*j) / float64(n*n)
			pCol := float64((n-j)*i) / float64(n*n)
			pRow := float64((n-i)*j) / float64(n*n)
			pRowCol := float64((n-j)*(n-i)) / float64(n*n)

			expect[i][j+1] += (expect[i][j]*pCol/(1-p) + pCol/(1-p)/(1-p)*prob[i][j])
			expect[i+1][j] += (expect[i][j]*pRow/(1-p) + pRow/(1-p)/(1-p)*prob[i][j])
			expect[i+1][j+1] += (expect[i][j]*pRowCol/(1-p) + pRowCol/(1-p)/(1-p)*prob[i][j])

			prob[i][j+1] += pCol / (1 - p) * prob[i][j]
			prob[i+1][j] += pRow / (1 - p) * prob[i][j]
			prob[i+1][j+1] += pRowCol / (1 - p) * prob[i][j]
		}
	}
	fmt.Printf("%f", expect[n][n])
}


using System;
using System.Collections.Generic;
using System.Linq;
class Problem
{
    void Solve()
    {
        var sc = new Scanner();
        var n = sc.Integer();
        var m = sc.Integer();
        int R, C;
        var usedR = new bool[n + 1];
        var usedC = new bool[n + 1];
        R = C = n;
        for (int i = 0; i < m; i++)
        {
            var r = sc.Integer();
            var c = sc.Integer();
            if (!usedR[r])
                R--;
            if (!usedC[c])
                C--;
            usedR[r] = usedC[c] = true;
        }
        var dp = Enumerable.Repeat(1, 2050).Select(x => Enumerable.Repeat(-1.0, 2050).ToArray()).ToArray();
        dp[0][0] = 0;
        Func<int, int, double> dfs = null;
        dfs = (raw, col) =>
            {
                if (raw < 0 || col < 0)
                    return 0;
                if (dp[raw][col] >= 0)
                    return dp[raw][col];
                double xc = raw * (n - col), yc = (n - raw) * col, xyc = raw * col, c = (n - raw) * (n - col);
                xc /= n * n - c; yc /= n * n - c; xyc /= n * n - c; c /= n * n;
                var ret = 1 / (1 - c);
                ret += xc * dfs(raw - 1, col);
                ret += yc * dfs(raw, col - 1);
                ret += xyc * dfs(raw - 1, col - 1);
                return dp[raw][col] = ret;

            };
        var res = dfs(R, C);
        Console.WriteLine(res.ToStringEx());

    }
    static void Main()
    {
#if DEBUG
        var ostream = new System.IO.FileStream("debug.txt", System.IO.FileMode.Create, System.IO.FileAccess.Write);
        var iStream = new System.IO.FileStream("input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        System.Diagnostics.Debug.AutoFlush = true;
        System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(new System.IO.StreamWriter(ostream, System.Text.Encoding.UTF8)));
        try
        {
#endif
            var problem = new Problem();
            problem.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
        }
        System.Diagnostics.Debug.Flush();
        Console.ReadKey(true);
#endif
    }

}

#region
public static partial class stringEx
{
    static public System.Globalization.CultureInfo CultureInfo { get; set; }
    static stringEx()
    {
        CultureInfo = System.Globalization.CultureInfo.InvariantCulture;
    }
    static public string ToStringEx(this double number, string format = null)
    {
        if (format == null)
            return number.ToString(CultureInfo);
        return number.ToString(format, CultureInfo);
    }
    static public string ToStringEx(this int number, string format = null)
    {
        if (format == null)
            return number.ToString(CultureInfo);
        return number.ToString(format, CultureInfo);
    }
    static public string ToStringEx(this long number, string format = null)
    {
        if (format == null)
            return number.ToString(CultureInfo);
        return number.ToString(format, CultureInfo);
    }
    static public string ToStringEx(this object arg, string format = null)
    {
        if (format == null)
            return string.Format(CultureInfo, "{0}", arg);
        return string.Format(CultureInfo, format, arg);
    }
    static public string ToConcatedString<T>(this IEnumerable<T> args)
    {
        var sb = new System.Text.StringBuilder();
        foreach (var arg in args)
            sb.AppendFormat(CultureInfo, "{0}", arg);
        return sb.ToString();
    }
    static public string ToJoinedString<T>(this IEnumerable<T> args, string separator = null)
    {
        var sb = new System.Text.StringBuilder();
        var s = separator??" ";
        foreach (var arg in args)
        {
            sb.AppendFormat(CultureInfo, "{0}", arg);
            sb.Append(s);
        }
        return sb.ToString(0, sb.Length - s.Length);

    }

}

public class Scanner
{
    readonly System.IO.TextReader reader;
    string[] buffer = new string[0];
    int position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null)
    {

        this.reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        this.Separator = separator.ToCharArray();

    }
    public string Scan()
    {
        if (this.position < this.buffer.Length)
            return this.buffer[this.position++];
        this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        this.position = 0;
        return this.buffer[this.position++];
    }

    public string[] ScanToEndLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        var size = this.buffer.Length - this.position;
        var ar = new string[size];
        Array.Copy(this.buffer, position, ar, 0, size);
        return ar;

    }

    public string ScanLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine();
        else
        {
            var sb = new System.Text.StringBuilder();
            for (; this.position < buffer.Length; this.position++)
            {
                sb.Append(this.buffer[this.position]);
                sb.Append(' ');
            }
            return sb.ToString();
        }
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
        {
            ar[i] = this.Scan();
        }
        return ar;
    }

    public int Integer()
    {
        return int.Parse(this.Scan());
    }
    public long Long()
    {
        return long.Parse(this.Scan());
    }
    public double Double()
    {
        return double.Parse(this.Scan());
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Double();
        return a;
    }

}
static public partial class EnumerableEx
{
    static public string AsString(this IEnumerable<char> source)
    {
        return new string(source.ToArray());
    }
    static public IEnumerable<T> Enumerate<T>(this int count, Func<int, T> selector)
    {
        return Enumerable.Range(0, count).Select(x => selector(x));
    }
}
#endregion
//*/


using System;
using System.Collections.Generic;
using System.Linq;
class Problem
{
    void Solve()
    {
        var sc = new Scanner();
        var n = sc.Integer();
        var m = sc.Integer();
        int R, C;
        var usedR = new bool[n + 1];
        var usedC = new bool[n + 1];
        R = C = n;
        for (int i = 0; i < m; i++)
        {
            var r = sc.Integer();
            var c = sc.Integer();
            if (!usedR[r])
                R--;
            if (!usedC[c])
                C--;
            usedR[r] = usedC[c] = true;
        }
        var dp = Enumerable.Repeat(1, 2050).Select(x => Enumerable.Repeat(-1.0, 2050).ToArray()).ToArray();
        dp[0][0] = 0;
        Func<int, int, double> dfs = null;
        dfs = (raw, col) =>
            {
                if (raw < 0 || col < 0)
                    return 0;
                if (dp[raw][col] >= 0)
                    return dp[raw][col];
                double xc = raw * (n - col), yc = (n - raw) * col, xyc = raw * col, c = (n - raw) * (n - col);
                xc /= n * n - c; yc /= n * n - c; xyc /= n * n - c; c /= n * n;
                var ret = 1 / (1 - c);
                ret += xc * dfs(raw - 1, col);
                ret += yc * dfs(raw, col - 1);
                ret += xyc * dfs(raw - 1, col - 1);
                return dp[raw][col] = ret;

            };
        var res = dfs(R, C);
        Console.WriteLine(res);

    }
    static void Main()
    {
        // For CodeForces
#if ONLINE_JUDGE
        System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
#endif
#if DEBUG
        var ostream = new System.IO.FileStream("debug.txt", System.IO.FileMode.Open, System.IO.FileAccess.Write);
        var iStream = new System.IO.FileStream("input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        System.Diagnostics.Debug.AutoFlush = true;
        System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(new System.IO.StreamWriter(ostream, System.Text.Encoding.UTF8)));
        try
        {
#endif
            var problem = new Problem();
            problem.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
        }
        Console.ReadKey(true);
#endif
    }

}

public class Scanner
{
    readonly System.IO.TextReader reader;
    string[] buffer = new string[0];
    int position;

    public char[] Separator { get; set; }
    public Scanner(System.IO.TextReader reader = null, string separator = null)
    {
        if (reader == null)
            this.reader = Console.In;
        else
            this.reader = reader;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        this.Separator = separator.ToCharArray();

    }
    public string Scan()
    {
        if (this.position < this.buffer.Length)
            return this.buffer[this.position++];
        this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        this.position = 0;
        return this.buffer[this.position++];
    }

    public string[] ScanToEndLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        var size = this.buffer.Length - this.position;
        var ar = new string[size];
        Array.Copy(this.buffer, position, ar, 0, size);
        return ar;

    }

    public string ScanLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine();
        else
        {
            var sb = new System.Text.StringBuilder();
            for (; this.position < buffer.Length; this.position++)
            {
                sb.Append(this.buffer[this.position]);
                sb.Append(' ');
            }
            return sb.ToString();
        }
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
        {
            ar[i] = this.Scan();
        }
        return ar;
    }

    public int Integer()
    {
        return int.Parse(this.Scan());
    }
    public long Long()
    {
        return long.Parse(this.Scan());
    }
    public double Double()
    {
        return double.Parse(this.Scan());
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Double();
        return a;
    }

}
static public partial class EnumerableEx
{
    static public string AsString(this IEnumerable<char> source)
    {
        return new string(source.ToArray());
    }
    static public IEnumerable<T> Enumerate<T>(this int count, Func<int, T> selector)
    {
        return Enumerable.Range(0, count).Select(x => selector(x));
    }
}
//*/


#define NDEBUG
#include <cstdio>
#include <iostream>
#include <unordered_set>
using namespace std;

#define repeat(n) for (int repc = (n); repc > 0; --repc)

int main() {
  cin.sync_with_stdio(0);

  int n, m;
  cin >> n >> m;

  unordered_set<char> haver, havec;
  repeat (m) {
    int y, x;
    cin >> y >> x;
    haver.insert(y);
    havec.insert(x);
  }

  static long double dp[2002][2002];
  for (int nr=n; nr>=0; --nr) {
    for (int nc=n; nc>=0; --nc) {
      if (nr == n && nc == n) {
        dp[nr][nc] = 0.0;
        continue;
      }

      long double e = n*n;
      e += nr * (n-nc) * dp[nr][nc+1];
      e += (n-nr) * nc * dp[nr+1][nc];
      e += (n-nr) * (n-nc) * dp[nr+1][nc+1];
      e /= n*n - nr*nc;
      dp[nr][nc] = e;
    }
  }

  printf("%.10f\n", double(dp[haver.size()][havec.size()]));
  return 0;
}


#define NDEBUG
#include <cstdio>
#include <iostream>
#include <unordered_set>
using namespace std;

#define repeat(n) for (int repc = (n); repc > 0; --repc)

int main() {
  cin.sync_with_stdio(0);

  int n, m;
  cin >> n >> m;

  unordered_set<int> haver, havec;
  repeat (m) {
    int y, x;
    cin >> y >> x;
    haver.insert(y);
    havec.insert(x);
  }

  static long double dp[2002][2002];
  for (int nr=n; nr>=0; --nr) {
    for (int nc=n; nc>=0; --nc) {
      if (nr == n && nc == n) {
        dp[nr][nc] = 0.0;
        continue;
      }

      long double e = n*n;
      e += nr * (n-nc) * dp[nr][nc+1];
      e += (n-nr) * nc * dp[nr+1][nc];
      e += (n-nr) * (n-nc) * dp[nr+1][nc+1];
      e /= n*n - nr*nc;
      dp[nr][nc] = e;
    }
  }

  printf("%.10f\n", double(dp[haver.size()][havec.size()]));
  return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
#define fr(i,a,b) for(int i = a; i < b; ++i)
#define rep(i, n) fr(i,0,n)
#define N 2010
#define ft first
#define sd second
typedef pair<int,int> pii;

double memo[N][N];
int n, m;

double rec(int l, int c){
    if(l < 0 || c < 0) return 0;
    if(l == c && l == 0) return 0;

    double tot = n * (l + c) - l * c, all = n*n;
    double& pd = memo[l][c];
    if(pd == pd) return pd;

    pd = 1 + (l*c/all) * rec(l-1,c-1) + (l*(n-c)/all)*rec(l-1, c) + (c*(n-l)/all)*rec(l, c-1);
    pd /= (1 - (n*n-tot) / all);

    return pd;
}

vector<pii> paint;
int main(){
    ios::sync_with_stdio(false);

    cin >> n >> m;
    rep(i, m){
        pii tmp;
        cin >> tmp.ft >> tmp.sd;
        paint.push_back(tmp);
    }
    set<int> col, row;
    for(pii par : paint) row.insert(par.ft), col.insert(par.sd);

    memset(memo, -1, sizeof memo);
    double ans = rec(n - row.size(), n - col.size());
    cout << ans << endl;
}


#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long       LL;
typedef pair<int, int>  PII;
typedef vector<int>     VI;
typedef vector<PII>     VPII;
#define MM(a,x) memset(a,x,sizeof(a));
#define ALL(x)  (x).begin(), (x).end()
#define P(x)	cerr<<"["#x<<" = "<<(x)<<"]"<<endl;
#define PP(x,i)	cerr<<"["#x<<i<<" = "<<x[i]<<"]"<<endl;
#define P2(x,y)	cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<"]"<<endl;
#define TM(a,b)	cerr<<"["#a" -> "#b": "<<1e3*(b-a)/CLOCKS_PER_SEC<<"ms]\n";
#define ASSERT(e) if(!(e)) {cerr<<"!!!ASSERTION FAILED!!! in #"<<__LINE__<<": " <<#e; exit(0);}
#define UN(v)   sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define x first
#define y second
struct _ {_() {ios_base::sync_with_stdio(0);}} _;
template<class A, class B> ostream& operator<<(ostream &o, pair<A, B> t) {o << "(" << t.x << ", " << t.y << ")"; return o;}
template<class T> string tostring(T x, int len = 0, char c = '0') {stringstream ss; ss << x; string r = ss.str(); if(r.length() < len) r = string(len - r.length(), c) + r; return r;}
template<class T> void PV(T a, T b, int n = 0, int w = 0, string s = " ") {int c = 0; while(a != b) {cout << tostring(*a++, w, ' '); if(a != b && (n == 0 || ++c % n)) cout << s; else cout << endl;}}
template<class T> inline bool chmin(T &a, T b) {return a > b ? a = b, 1 : 0;}
template<class T> inline bool chmax(T &a, T b) {return a < b ? a = b, 1 : 0;}
const LL linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 2222;

int n, m;
bool rr[N];
bool cc[N];
double dp[N][N];

double f(int nr, int nc) {
	if(nr < 0) return 0;
	if(nc < 0) return 0;
	double &res = dp[nr][nc];
	if(res < -inf / 2) {
		res = 0;
		double p0 = (double) (n - nc) * nr / n / n;
		double p1 = (double) (n - nr) * nc / n / n;
		double p2 = (double) nr * nc / n / n;
		double p3 = (double) (n - nc) * (n - nr) / n / n;
		if(nr + nc > 0) {
			res += f(nr - 1, nc) * p0;
			res += f(nr, nc - 1) * p1;
			res += f(nr - 1, nc - 1) * p2;
			res++;
			res /= (1 - p3);
		}
	}
	return res;
}

int main() {
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		rr[x] = 1;
		cc[y] = 1;
	}
	int nr = 0, nc = 0;
	for(int i = 1; i <= n; i++) if(rr[i] == 0) nr++;
	for(int i = 1; i <= n; i++) if(cc[i] == 0) nc++;
	fill(&dp[0][0], &dp[N][0], -inf);
	double res = f(nr, nc);
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}


#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <vector>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long       LL;
typedef pair<int, int>  PII;
typedef vector<int>     VI;
typedef vector<PII>     VPII;
#define MM(a,x) memset(a,x,sizeof(a));
#define ALL(x)  (x).begin(), (x).end()
#define P(x)	cerr<<"["#x<<" = "<<(x)<<"]"<<endl;
#define PP(x,i)	cerr<<"["#x<<i<<" = "<<x[i]<<"]"<<endl;
#define P2(x,y)	cerr<<"["#x" = "<<(x)<<", "#y" = "<<(y)<<"]"<<endl;
#define TM(a,b)	cerr<<"["#a" -> "#b": "<<1e3*(b-a)/CLOCKS_PER_SEC<<"ms]\n";
#define ASSERT(e) if(!(e)) {cerr<<"!!!ASSERTION FAILED!!! in #"<<__LINE__<<": " <<#e; exit(0);}
#define UN(v)   sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define x first
#define y second
struct _ {_() {ios_base::sync_with_stdio(0);}} _;
template<class A, class B> ostream& operator<<(ostream &o, pair<A, B> t) {o << "(" << t.x << ", " << t.y << ")"; return o;}
template<class T> string tostring(T x, int len = 0, char c = '0') {stringstream ss; ss << x; string r = ss.str(); if(r.length() < len) r = string(len - r.length(), c) + r; return r;}
template<class T> void PV(T a, T b, int n = 0, int w = 0, string s = " ") {int c = 0; while(a != b) {cout << tostring(*a++, w, ' '); if(a != b && (n == 0 || ++c % n)) cout << s; else cout << endl;}}
template<class T> inline bool chmin(T &a, T b) {return a > b ? a = b, 1 : 0;}
template<class T> inline bool chmax(T &a, T b) {return a < b ? a = b, 1 : 0;}
const LL linf = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 2222;

int n, m;
bool d[N][N];
bool rr[N];
bool cc[N];
double dp[N][N];

double f(int nr, int nc) {
	double &res = dp[nr][nc];
	if(res < -inf / 2) {
		res = 0;
		double p0 = (double) (n - nc) * nr / n / n;
		double p1 = (double) (n - nr) * nc / n / n;
		double p2 = (double) nr * nc / n / n;
		double p3 = (double) (n - nc) * (n - nr) / n / n;
		if(nr < 0 || nc < 0 || nr + nc == 0) res = 0;
		else {
			res += f(nr - 1, nc) * p0;
			res += f(nr, nc - 1) * p1;
			res += f(nr - 1, nc - 1) * p2;
			res++;
			res /= (1 - p3);
		}
	}
	return res;
}

int main() {
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		d[x][y] = 1;
		rr[x] = 1;
		cc[y] = 1;
	}
	int nr = 0, nc = 0;
	for(int i = 1; i <= n; i++) if(rr[i] == 0) nr++;
	for(int i = 1; i <= n; i++) if(cc[i] == 0) nc++;
	fill(&dp[0][0], &dp[N][0], -inf);
	double res = f(nr, nc);
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}


#include <iostream>
using namespace std;

const int MAXN = 2048;

int N, M; double NN;
double ans[MAXN][MAXN];
double fra[MAXN], frb[MAXN][MAXN];
bool pr[MAXN], pc[MAXN];

int main(){
    ios_base::sync_with_stdio(false);
    cin >> N >> M;
    NN = N;

    for(int i=0; i<=N; i++)
        fra[i] = i/NN;

    for(int i=0; i<=N; i++)
        for(int j=0; j<=N; j++)
            frb[i][j] = fra[i] * fra[j];

    ans[0][0] = 0;
    for(int ur=0; ur<=N; ur++)
        for(int uc=0; uc<=N; uc++){
            if(!(ur+uc)) continue;
            double stay = frb[N-ur][N-uc];
            double rhs = 1;
            if(ur) rhs += frb[ur][N-uc] * ans[ur-1][uc];
            if(uc) rhs += frb[N-ur][uc] * ans[ur][uc-1];
            if(ur && uc) rhs += frb[ur][uc] * ans[ur-1][uc-1];
            ans[ur][uc] = rhs / (1 - stay);
        }

    int UR = N, UC = N;

    for(int i=0; i<M; i++){
        int x, y;
        cin >> x >> y;
        if(!pr[x-1]){ pr[x-1] = true; UR--; }
        if(!pc[y-1]){ pc[y-1] = true; UC--; }
    }

    cout.precision(20);
    cout << ans[UR][UC] << endl;
    return 0;
}