#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>
 
#define N 305
#define M 8000005
 
#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)
 
#define mk make_pair
#define pb push_back
#define fi first
#define se second
 
#define Mo 1000000007
#define g 3
 
using namespace std;

int f[N*2][N][N],cnt,i,j,m,n,p,k,a[N*2],vis[N*2];

void jia(int &x,int y)
{
		x+=y; if (x>=Mo) x-=Mo;
}

int main()
{
		scanf("%d",&n);
		for (i=1;i<=2*n;++i)
		{
				scanf("%d",&a[i]);
				if (a[i]!=-1) a[i]=2*n-a[i]+1;
		}
		for (i=1;i<=2*n;i+=2) 
				if (a[i]!=-1&&a[i+1]!=-1) vis[a[i]]=vis[a[i+1]]=1;
				else if (a[i]!=-1) vis[a[i]]=2;
				else if (a[i+1]!=-1) vis[a[i+1]]=2;
				else cnt++;
		f[0][0][0]=1;
		int P=0,L=0;
		for (i=1;i<=2*n;++i)
		{
			for (j=0;j<=cnt;++j)
				for (k=0;k<=n;++k)
					if (f[i-1][j][k])
					{
							if (vis[i]==1) f[i][j][k]=f[i-1][j][k];
							else if (vis[i]==2)
							{
									int rest=P-(2*j+L-k);
									if (rest>0) jia(f[i][j][k],f[i-1][j][k]);
									jia(f[i][j][k+1],f[i-1][j][k]);
							}
							else
							{
									jia(f[i][j][k],f[i-1][j][k]);
									if (k>0)  
									jia(f[i][j][k-1],1ll*k*f[i-1][j][k]%Mo);
									int rest=P-(2*j+L-k);
									if (rest>0&&cnt>j) jia(f[i][j+1][k],1ll*f[i-1][j][k]*(cnt-j)%Mo);
							}
					}
			if (vis[i]==0) P++;
			if (vis[i]==2) L++;
		}
	   printf("%d\n",f[2*n][cnt][0]);
}
