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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}
template<::std::uint_fast64_t mod>
class ModInt{
private:
	using value_type = ::std::uint_fast64_t;
	value_type n;
public:
	ModInt() : n(0) {}
	ModInt(value_type n_) : n(n_ % mod) {}
	ModInt(const ModInt& m) : n(m.n) {}

	template<typename T>
	explicit operator T() const { return static_cast<T>(n); }
	value_type get() const { return n; }

	friend ::std::ostream& operator<<(::std::ostream &os, const ModInt<mod> &a) {
		return os << a.n;
	}

	friend ::std::istream& operator>>(::std::istream &is, ModInt<mod> &a) {
		value_type x;
		is >> x;
		a = ModInt<mod>(x);
		return is;
	}

	bool operator==(const ModInt& m) const { return n == m.n; }
	bool operator!=(const ModInt& m) const { return n != m.n; }
	ModInt& operator*=(const ModInt& m){ n = n * m.n % mod; return *this; }

	ModInt pow(value_type b) const{
		ModInt ans = 1, m = ModInt(*this);
		while(b){
			if(b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}

	ModInt inv() const { return (*this).pow(mod-2); }
	ModInt& operator+=(const ModInt& m){ n += m.n; n = (n < mod ? n : n - mod); return *this; }
	ModInt& operator-=(const ModInt& m){ n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	ModInt& operator/=(const ModInt& m){ *this *= m.inv(); return *this; }
	ModInt operator+(const ModInt& m) const { return ModInt(*this) += m; }
	ModInt operator-(const ModInt& m) const { return ModInt(*this) -= m; }
	ModInt operator*(const ModInt& m) const { return ModInt(*this) *= m; }
	ModInt operator/(const ModInt& m) const { return ModInt(*this) /= m; }
	ModInt& operator++(){ n += 1; return *this; }
	ModInt& operator--(){ n -= 1; return *this; }
	ModInt operator++(int){
		ModInt old(n);
		n += 1;
		return old;
	}
	ModInt operator--(int){
		ModInt old(n);
		n -= 1;
		return old;
	}
	ModInt operator-() const { return ModInt(mod-n); }
};

const int64 mod = 1e9+7;

using Mint = ModInt<mod>;

int main(void) {
	int N;
	cin >> N;
	vector<int64> A(2*N), sc1(2*N+1, 0);
	vector<bool> used(2*N+1, 0), ispair(2*N+1, 0);
	int cnt[3] = {};
	int luz = 0;
	REP(i, 2*N) {
		cin >> A[i];
		if (A[i] != -1) used[A[i]-1] = 1;
		if (A[i] != -1) luz += 1;
		if (i%2) {
			cnt[(A[i-1] != -1) + (A[i] != -1)]++;
			if ((A[i-1] != -1) + (A[i] != -1) == 1) {
				sc1[max(A[i-1], A[i])]++;
			} else if ((A[i-1] != -1) + (A[i]!=-1) == 2) {
				ispair[A[i-1]-1] = 1;
				ispair[A[i]-1] = 1;
			}
		}
	}
	REP(i, 2*N) sc1[i+1] += sc1[i];
	vector<vector<Mint>> dp(310, vector<Mint>(310, 0));
	dp[cnt[0]][cnt[1]] = Mint(1);
	REP(i, 2*N) {
		vector<vector<Mint>> dp2(310, vector<Mint>(310, 0));
		REP(j, N+1) { // [-, -] のかず
			REP(k, N+1) { // [-, *]かつ*>iの数
				int64 rest = N-j-k;
				int64 latte = luz-k-rest; // [*, *]
				int64 beet = rest-latte; // [-, *]かつ*<i
				if (j < 0 || k < 0 || rest < 0 || latte < 0 || beet <0) continue;
				if (used[i]) {
					if (ispair[i]) {
						dp2[j][k] += dp[j][k];
					} else {
						Mint exist_posi = Mint(k)/Mint(sc1[2*N]-sc1[i]), inv_posi = Mint(sc1[2*N]-sc1[i]-k)/Mint(sc1[2*N]-sc1[i]);
						if (k > 0)
							dp2[j][k-1] += dp[j][k] * exist_posi;
						dp2[j][k] += dp[j][k] * inv_posi;
					}
				} else {
					if (j > 0)
						dp2[j-1][k] += dp[j][k] * j;
					if (k > 0)
						dp2[j][k-1] += dp[j][k] * k;
					if (beet > 0)
						dp2[j][k] += dp[j][k];
				}
			}
		}
		if (!used[i]) luz++;
		swap(dp, dp2);
	}
	cout << dp[0][0] << endl;
}


Measured memory_bytes: 1840