#include <bits/stdc++.h>
using namespace std;

namespace TYC
{
	typedef long long ll;
	const int N = 605, mod = 1e9 + 7;

	int n, A[N], P[N], F[2][N][N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	inline void add(int &a, const int b) { a = (a + b) % mod; }

	void work()
	{
		n = read() << 1;
		for (int i = 1; i <= n; i++)
			if (~(A[i] = read()))
				P[A[i]] = 1;
		int cnt = 0;
		for (int i = 1; i <= n; i += 2)
			if (~A[i] && ~A[i + 1])
				P[A[i]] = P[A[i + 1]] = 2;	
			else if (A[i] == -1 && A[i + 1] == -1)
				cnt++;
		F[n & 1][0][0] = 1;
		for (int i = n, c[2] = {0}; i; i--)
		{
			int d = i & 1;
			if (P[i] == 2)
				memcpy(F[d ^ 1], F[d], sizeof(F[d]));
			else
			{
				memset(F[d ^ 1], 0, sizeof(F[d ^ 1]));
				for (int j = 0, v; j <= c[1]; j++)
					for (int k = 0; k <= c[0]; k++)
						if ((v = F[d][j][k]))
						{
							if (P[i] == 0)
							{
								if (j)
									add(F[d ^ 1][j - 1][k], int((ll)v * j % mod));
								if (k)
									add(F[d ^ 1][j][k - 1], v);
								add(F[d ^ 1][j][k + 1], v);	
							}
							else if (P[i] == 1)
							{
								add(F[d ^ 1][j + 1][k], v);
								if (k)
									add(F[d ^ 1][j][k - 1], v);
							}
						}
				c[P[i]]++;
			}
		}
		int ans = F[0][0][0];
		for (int i = 1; i <= cnt; i++)
			ans = int((ll)ans * i % mod);
		printf("%d\n", ans);
	}
}

int main()
{
	TYC::work();
	return 0;
}