/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author RiaD
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <array>
#include <map>


#include <vector>
#include <type_traits>

template <typename T, size_t N>
struct MakeVector {
	template <
			typename... Args,
			typename R = std::vector<decltype(MakeVector<T, N - 1>::make_vector(std::declval<Args>()...))>
	>
	static R make_vector(std::size_t first, Args... sizes) {
		auto inner = MakeVector<T, N - 1>::make_vector(sizes...);
		return R(first, inner);
	}
};

template <typename T>
struct MakeVector<T, 1> {
	/*
	 * This template is to fool CLion.
	 * Without it CLion thinks that make_vector always returns std::vector<T> and marks code like
	 *
	 * auto dp = make_vector<int>(n, m, 0);
	 * dp[0][0] = 1 as error because it suppose that dp[0] is int
	 *
	 * TODO: Consider removing it once https://youtrack.jetbrains.com/issue/CPP-3340 is fixed
	 */
	template <typename R = std::vector<T>>
	static R make_vector(std::size_t size, const T& value) {
		return R(size, value);
	}
};

template <typename T, typename... Args>
auto make_vector(Args... args) -> decltype(MakeVector<T, sizeof...(Args) - 1>::make_vector(args...)) {
	return MakeVector<T, sizeof...(Args) - 1>::make_vector(args...);
}






#include <string>
#include <stdexcept>

#ifndef SPCPPL_ASSERT
	#ifdef SPCPPL_DEBUG
		#define SPCPPL_ASSERT(condition) \
		if(!(condition)) { \
			throw std::runtime_error(std::string() + #condition + " in line " + std::to_string(__LINE__) + " in " + __PRETTY_FUNCTION__); \
		}
	#else
		#define SPCPPL_ASSERT(condition)
	#endif
#endif



#include <cstddef>

namespace impl {

template <typename T, typename U, typename V>
void matrixMultiplication(const T& lhs, const U& rhs, V& res) {
	const auto& a = lhs;
	auto b = rhs.transposed();
	for (std::size_t i = 0; i < lhs.rows(); ++i) {
		for (std::size_t j = 0; j < rhs.columns(); ++j) {
			for (std::size_t k = 0; k < rhs.rows(); ++k) {
				res[i][j] += a[i][k] * b[j][k];
			}
		}
	}
}

} // namespace impl





template <typename T, typename = std::true_type>
struct IdentityHelper;

template <typename T>
struct IdentityHelper<T, typename std::is_arithmetic<T>::type> {
	static T identity() {
		return 1;
	}
};

template <typename T>
T identity() {
	return IdentityHelper<T>::identity();
}



template <typename T, typename N, typename M>
class Matrix {
public:
	explicit Matrix(const T& value = T()): value(make_vector<T>(rows(), columns(), value)) {

	}

	std::size_t rows() const {
		return N::value;
	}

	std::size_t columns() const {
		return M::value;
	}

	std::vector<T>& operator[](std::size_t index) {
		SPCPPL_ASSERT(index < rows());
		return value[index];
	}

	const std::vector<T>& operator[](std::size_t index) const {
		SPCPPL_ASSERT(index < rows());
		return value[index];
	}

	Matrix& operator*=(const Matrix<T, M, M>& rhs) {
		return *this = *this * rhs;
	}

	Matrix& operator+=(const Matrix& rhs) {
		for (std::size_t i = 0; i < rows(); ++i) {
			for (std::size_t j = 0; j < columns(); ++j) {
				value[i][j] += rhs.value[i][j];
			}
		}
		return *this;
	}

	Matrix operator-() const {
		Matrix copy = *this;
		for (int i = 0; i < rows(); ++i) {
			for (int j = 0; j < columns(); ++j) {
				copy[i][j] = -copy[i][j];
			}
		}
		return copy;
	}

	Matrix operator-=(const Matrix& rhs) {
		return *this += -rhs;
	}

	Matrix<T, M, N> transposed() const {
		Matrix<T, M, N> res;
		for (std::size_t i = 0; i < rows(); ++i) {
			for (std::size_t j = 0; j < columns(); ++j) {
				res[j][i] = value[i][j];
			}
		}
		return res;
	}

private:
	std::vector<std::vector<T>> value;

	template <typename U, typename V, typename W>
	friend bool operator==(const Matrix<U, V, W>& lhs, const Matrix<U, V, W>& rhs);
};

template <typename T, typename N, typename M>
bool operator==(const Matrix<T, N, M>& lhs, const Matrix<T, N, M>& rhs) {
	return lhs.value == rhs.value;
}

template <typename T, typename N, typename M, typename K>
Matrix<T, N, K> operator*(const Matrix<T, N, M>& lhs, const Matrix<T, M, K>& rhs) {
	Matrix<T, N, K> res;
	impl::matrixMultiplication(lhs, rhs, res);
	return res;
}

template <typename T, typename N, typename M>
Matrix<T, N, M> operator+(Matrix<T, N, M> lhs, const Matrix<T, N, M>& rhs) {
	Matrix<T, N, M> copy = std::move(lhs);
	return copy += rhs;
}

template <typename T, typename N, typename M>
Matrix<T, N, M> operator-(Matrix<T, N, M> lhs, const Matrix<T, N, M>& rhs) {
	Matrix<T, N, M> copy = std::move(lhs);
	return copy -= rhs;
}

template <typename T, typename N>
struct IdentityHelper<Matrix<T, N, N>> {
	static Matrix<T, N, N> identity() {
		Matrix<T, N, N> res;
		for (std::size_t i = 0; i < N::value; ++i) {
			res[i][i] = ::identity<T>();
		}
		return res;
	}
};

template <typename T, std::size_t n, std::size_t m>
using FixedSizeMatrix = Matrix<T, std::integral_constant<std::size_t, n>, std::integral_constant<std::size_t, m>>;



#include <iterator>


/**
* Support decrementing and multi-passing, but not declared bidirectional(or even forward) because
* it's reference type is not a reference.
*
* It doesn't return reference because
* 1. Anyway it'll not satisfy requirement [forward.iterators]/6
*   If a and b are both dereferenceable, then a == b if and only if *a and
*   b are bound to the same object.
* 2. It'll not work with reverse_iterator that returns operator * of temporary which is temporary for this iterator
*
* Note, reverse_iterator is not guaranteed to work  now too since it works only with bidirectional iterators,
* but it's seems to work at least on my implementation.
*
* It's not really useful anywhere except iterating anyway.
*/
template <typename T>
class IntegerIterator: public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> {
public:
	explicit IntegerIterator(T value): value(value) {

	}

	IntegerIterator& operator++() {
		++value;
		return *this;
	}

	IntegerIterator operator++(int) {
		IntegerIterator copy = *this;
		++value;
		return copy;
	}

	IntegerIterator& operator--() {
		--value;
		return *this;
	}

	IntegerIterator operator--(int) {
		IntegerIterator copy = *this;
		--value;
		return copy;
	}

	T operator*() const {
		return value;
	}

	bool operator==(IntegerIterator rhs) const {
		return value == rhs.value;
	}

	bool operator!=(IntegerIterator rhs) const {
		return !(*this == rhs);
	}

private:
	T value;
};

template <typename T>
class IntegerRange {
public:
	IntegerRange(T begin, T end): begin_(begin), end_(end) {
		SPCPPL_ASSERT(begin <= end);
	}

	IntegerIterator<T> begin() const {
		return IntegerIterator<T>(begin_);
	}

	IntegerIterator<T> end() const {
		return IntegerIterator<T>(end_);
	}

private:
	T begin_;
	T end_;
};

template <typename T>
class ReversedIntegerRange {
	typedef std::reverse_iterator<IntegerIterator<T>> IteratorType;
public:
	ReversedIntegerRange(T begin, T end): begin_(begin), end_(end) {
		SPCPPL_ASSERT(begin >= end);
	}

	IteratorType begin() const {
		return IteratorType(IntegerIterator<T>(begin_));
	}

	IteratorType end() const {
		return IteratorType(IntegerIterator<T>(end_));
	}

private:
	T begin_;
	T end_;
};

template <typename T>
IntegerRange<T> range(T to) {
	return IntegerRange<T>(0, to);
}

template <typename T>
IntegerRange<T> range(T from, T to) {
	return IntegerRange<T>(from, to);
}

template <typename T>
IntegerRange<T> inclusiveRange(T to) {
	return IntegerRange<T>(0, to + 1);
}

template <typename T>
IntegerRange<T> inclusiveRange(T from, T to) {
	return IntegerRange<T>(from, to + 1);
}

template <typename T>
ReversedIntegerRange<T> downrange(T from) {
	return ReversedIntegerRange<T>(from, 0);
}

template <typename T>
ReversedIntegerRange<T> downrange(T from, T to) {
	return ReversedIntegerRange<T>(from, to);
}

template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from) {
	return ReversedIntegerRange<T>(from + 1, 0);
}

template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from, T to) {
	return ReversedIntegerRange<T>(from + 1, to);
}




#include <assert.h>





/**
* ax + by = result
*/
template <typename T>
T extendedGcd(T a, T b, T& x, T& y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T d = extendedGcd(b % a, a, y, x);
	x -= (b / a) * y;
	return d;
}

template <typename T>
class Zn {
public:
	Zn(): value(0) {
	}

	/**
	* Instead of ctor, to allow not to normalize in ctor
	*/
	static Zn valueOf(int value) {
		int x = value % mod();
		if (x < 0) {
			x += mod();
		}
		return Zn(x);
	}

	static Zn valueOf(long long value) {
		int x = static_cast<int>(value % mod());
		if (x < 0) {
			x += mod();
		}
		return Zn(x);
	}

	static Zn rawValueOf(int value) {
		SPCPPL_ASSERT(value >= 0 && value < mod());
		return Zn(value);
	}

	Zn& operator=(int rhs) {
		return *this = Zn::valueOf(rhs);
	}

	Zn& operator=(long long rhs) {
		return *this = Zn::valueOf(rhs);
	}

	Zn& operator+=(const Zn& rhs) {
		value += rhs.value;
		if (value >= mod()) {
			value -= mod();
		}
		return *this;
	}

	Zn& operator+=(int rhs) {
		return *this += Zn::valueOf(rhs);
	}

	Zn& operator+=(long long rhs) {
		return *this += Zn::valueOf(rhs);
	}

	Zn& operator-=(const Zn& rhs) {
		value -= rhs.value;
		if (value < 0) {
			value += mod();
		}
		return *this;
	}

	Zn& operator-=(int rhs) {
		return *this -= Zn::valueOf(rhs);
	}

	Zn& operator-=(long long rhs) {
		return *this -= Zn::valueOf(rhs);
	}

	Zn& operator*=(const Zn& rhs) {
		long long result = static_cast<long long>(value) * static_cast<long long>(rhs.value);
		value = static_cast<int>(result % mod());
		return *this;
	}

	Zn& operator*=(int rhs) {
		return *this *= Zn::valueOf(rhs);
	}

	Zn& operator*=(long long rhs) {
		return *this *= Zn::valueOf(rhs);
	}

	Zn operator-() const {
		if (value == 0) {
			return *this;
		}
		else {
			return Zn(mod() - value);
		}
	}

	Zn& operator/=(const Zn& rhs) {
		return *this *= rhs.inversed();
	}

	Zn& operator/=(int rhs) {
		return *this /= Zn::valueOf(rhs);
	}

	Zn& operator/=(long long rhs) {
		return *this /= Zn::valueOf(rhs);
	}

	bool operator==(const Zn& rhs) const {
		return value == rhs.value;
	}

	Zn inversed() const {
		SPCPPL_ASSERT(value != 0);

		int x, y;
		int gcd = extendedGcd(value, mod(), x, y);
		(void) gcd;
		SPCPPL_ASSERT(gcd == 1);

		if (x < 0) {
			x += mod();
		}
		return Zn(x);
	}

	template <typename U>
	friend std::ostream& operator<<(std::ostream&, const Zn<U>& zn);

	template <typename U>
	friend std::istream& operator>>(std::istream&, Zn<U>& zn);

	int intValue() const {
		return value;
	}

private:
	/**
	* No normalization performed
	*/
	explicit Zn(int value): value(value) {
	}

	int value;

	constexpr static int mod() {
		return T::value;
	}

	template <int N = T::value>
	static constexpr bool positive_or_runtime(int) {
		return N > 0;
	}
	static constexpr bool positive_or_runtime(...) {
		return true;
	}
	static_assert(
			std::is_same<typename std::decay<decltype(T::value)>::type, int>::value,
			"T::value must be int"
	);
	static_assert(positive_or_runtime(0), "Mod has to be positive integer");
};

template <typename T>
bool operator==(const Zn<T>& lhs, int rhs) {
	return lhs == Zn<T>::valueOf(rhs);
}

template <typename T>
bool operator==(int lhs, const Zn<T>& rhs) {
	return rhs == lhs;
}
template <typename T>
bool operator==(const Zn<T>& lhs, long long rhs) {
	return lhs == Zn<T>::valueOf(rhs);
}

template <typename T>
bool operator==(long long lhs, Zn<T>& rhs) {
	return rhs == lhs;
}

template <typename T>
bool operator!=(const Zn<T>& lhs, const Zn<T>& rhs) {
	return !(lhs == rhs);
}

template <typename T>
bool operator!=(const Zn<T>& lhs, int rhs) {
	return !(lhs == rhs);
}

template <typename T>
bool operator!=(int lhs, const Zn<T>& rhs) {
	return !(lhs == rhs);
}

template <typename T>
bool operator!=(const Zn<T>& lhs, long long rhs) {
	return !(lhs == rhs);
}

template <typename T>
bool operator!=(long long rhs, const Zn<T>& lhs) {
	return !(lhs == rhs);
}

template <typename T>
Zn<T> operator+(const Zn<T>& lhs, const Zn<T>& rhs) {
	Zn<T> copy = lhs;
	return copy += rhs;
}

template <typename T>
Zn<T> operator+(const Zn<T>& lhs, int rhs) {
	Zn<T> copy = lhs;
	return copy += rhs;
}

template <typename T>
Zn<T> operator+(int lhs, const Zn<T>& rhs) {
	return rhs + lhs;
}

template <typename T>
Zn<T> operator+(const Zn<T>& lhs, long long rhs) {
	Zn<T> copy = lhs;
	return copy += rhs;
}

template <typename T>
Zn<T> operator+(long long lhs, const Zn<T>& rhs) {
	return rhs + lhs;
}

template <typename T>
Zn<T> operator-(const Zn<T>& lhs, const Zn<T>& rhs) {
	Zn<T> copy = lhs;
	return copy -= rhs;
}

template <typename T>
Zn<T> operator-(const Zn<T>& lhs, int rhs) {
	Zn<T> copy = lhs;
	return copy -= rhs;
}

template <typename T>
Zn<T> operator-(int lhs, const Zn<T>& rhs) {
	return Zn<T>::valueOf(lhs) - rhs;
}

template <typename T>
Zn<T> operator-(const Zn<T>& lhs, long long rhs) {
	Zn<T> copy = lhs;
	return copy -= rhs;
}

template <typename T>
Zn<T> operator-(long lhs, const Zn<T>& rhs) {
	return Zn<T>::valueOf(lhs) - rhs;
}

template <typename T>
Zn<T> operator*(const Zn<T>& lhs, const Zn<T>& rhs) {
	Zn<T> copy = lhs;
	return copy *= rhs;
}

template <typename T>
Zn<T> operator*(const Zn<T>& lhs, int rhs) {
	Zn<T> copy = lhs;
	return copy *= rhs;
}

template <typename T>
Zn<T> operator*(int lhs, const Zn<T>& rhs) {
	return rhs * lhs;
}

template <typename T>
Zn<T> operator*(const Zn<T>& lhs, long long rhs) {
	Zn<T> copy = lhs;
	return copy *= rhs;
}

template <typename T>
Zn<T> operator*(long long lhs, const Zn<T>& rhs) {
	return rhs * lhs;
}

template <typename T>
Zn<T> operator/(const Zn<T>& lhs, const Zn<T>& rhs) {
	Zn<T> copy = lhs;
	return copy /= rhs;
}

template <typename T>
Zn<T> operator/(const Zn<T>& lhs, int rhs) {
	Zn<T> copy = lhs;
	return copy /= rhs;
}

template <typename T>
Zn<T> operator/(int lhs, const Zn<T>& rhs) {
	return Zn<T>::valueOf(lhs) / rhs;
}

template <typename T>
Zn<T> operator/(const Zn<T>& lhs, long long rhs) {
	Zn<T> copy = lhs;
	return copy /= rhs;
}

template <typename T>
Zn<T> operator/(long long lhs, const Zn<T>& rhs) {
	return Zn<T>::valueOf(lhs) / rhs;
}

template <typename T>
std::ostream& operator<<(std::ostream& stream, const Zn<T>& zn) {
	return stream << zn.value;
}

template <typename T>
std::istream& operator>>(std::istream& stream, Zn<T>& zn) {
	long long value;
	stream >> value;
	zn.value = static_cast<int>(value % T::value);
	return stream;
}

template <typename T>
struct IdentityHelper<Zn<T>> {
	static Zn<T> identity() {
		return Zn<T>::valueOf(1);
	}
};

template <int m>
using ZnConst = Zn<std::integral_constant<int, m>>;

#define MAKE_CONSTANT(name, type) \
		struct name { \
			static type value; \
		}; \
		type name::value;







#include <algorithm>



template <typename T, typename N, typename M>
std::size_t reduceToRowEchelonForm(Matrix<T, N, M>& matrix) {
	std::size_t rank = 0;

	for (std::size_t column: range(matrix.columns())) {
		bool found = false;
		for (std::size_t row: range(rank, matrix.rows())) {
			if (matrix[row][column] != 0) {
				using std::swap;
				found = true;
				swap(matrix[row], matrix[rank]);
				break;
			}
		}
		if (!found) {
			continue;
		}

		for (std::size_t r: range(rank + 1, matrix.rows())) {
			T multiplier = matrix[r][column] / matrix[rank][column];
			for (std::size_t c: range(column, matrix.columns())) {
				matrix[r][c] -= multiplier * matrix[rank][c];
			}
			SPCPPL_ASSERT(matrix[r][column] == 0);
		}
		++rank;
	}
	return rank;
}


template <typename T, typename N, typename M>
std::size_t matrixRank(Matrix<T, N, M> matrix) {
	return reduceToRowEchelonForm(matrix);
}






template <typename T>
T binpow(T base, long long power) {
	SPCPPL_ASSERT(power >= 0);
	T result = identity<T>();
	while (power > 0) {
		if (power & 1) {
			result *= base;
		}
		power >>= 1;
		base *= base;
	}
	return result;
}










template <bool b, typename T = void>
using enable_if_t = typename std::enable_if<b, T>::type;



template <typename T>
std::vector<T> factorials(std::size_t maxN) {
	std::vector<T> res(maxN + 1);
	res[0] = identity<T>();
	for (std::size_t i = 1; i <= maxN; ++i) {
		res[i] = res[i - 1] * static_cast<long long>(i);
	}
	return res;
}

template <typename T>
std::vector<std::vector<T>> binomials(std::size_t maxN) {
	std::vector<std::vector<T>> res(maxN + 1, std::vector<T>(maxN + 1));
	for (std::size_t n = 0; n <= maxN; ++n) {
		res[n][0] = identity<T>();
		res[n][n] = identity<T>();
		for (std::size_t k = 1; k < n; ++k) {
			res[n][k] = res[n - 1][k - 1] + res[n - 1][k];
		}
	}

	return res;
}

template <typename T, typename U, typename = enable_if_t<std::is_integral<U>::value>>
T binomial(U n, U k) {
	if (k > n || k < 0) {
		return T();
	}
	T res = identity<T>();
	for (U i: inclusiveRange(1, k)) {
		res *= n - i + 1;
		res /= i;
	}
	return res;
};

template <typename T, typename U, typename = enable_if_t<std::is_integral<U>::value>>
T starsAndBars(U stars, U groups) {
	if (groups == 0) {
		if (stars == 0) {
			return identity<T>();
		} else {
			return T();
		}
	}
	return binomial<T>(stars + groups - 1, groups - 1);
};


using namespace std;

MAKE_CONSTANT(N, size_t);
class TaskH {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n;
		in >> n;
		N::value = n;
		using Z2 = ZnConst<2>;
		Matrix<Z2, N, N> m;
		for (int i: range(n)) {
			for (int j: range(n)) {
				in >> m[i][j];
			}
		}

		int rk = (int) matrixRank(m);
		cerr << rk << endl;

		using Z = ZnConst<1000000007>;
		vector<Z> powers(1000000);
		powers[0] = 1;
		for (int i: range(1, (int)powers.size())) {
			powers[i] = powers[i - 1] * 2;
		}
		auto cnt = [&](int n, int r) {
			Z res = Z::rawValueOf(1);
			for (int i: range(r)) {
				res *= powers[n] - powers[i];
			}
			return res;
		};

		auto ways = [&](int h) {
			if (h >= n) {
				return Z();
			}
			return powers[n] - powers[h];
		};


		vector<Z> dp(n + 2);

		auto fact = factorials<Z>(n);

		auto s = make_vector<Z>(n + 1, n + 1, Z());
		s[0][0] = 1;

		for (int a: range(n)) {
			for (int b: range(n)) {
				s[a + 1][b + 1] += s[a][b] * (powers[n] - powers[b]);
			}
			for (int b: inclusiveRange(n)) {
				s[a + 1][b] += s[a][b] * powers[b];
			}
		}

		Z ans;
		for (int i: inclusiveRange(n)) {
			Z by_rank = s[n][i];
			cerr << i<< ' '<< by_rank << endl;
			ans += s[i][rk] * powers[(n - i) * n] * by_rank;
		}
		out << ans / s[n][rk];
		//for (int )
		//for (int k: inclusiveRange(n)) {
		//	auto s = make_vector<Z>(n + 1, k + 1, Z());
		//	s[0][0] = 1;
		//
		//	for (int a: range(n)) {
		//		for (int b: range(k)) {
		//			s[a + 1][b + 1] += s[a][b] * (powers[k] - powers[b]);
		//		}
		//		for (int b: inclusiveRange(k)) {
		//			s[a + 1][b] += s[a][b] * powers[b];
		//		}
		//	}
		//
		//	Z good;
		//	for (int a: inclusiveRange(k, n)) {
		//		good += s[n][a];
		//	}
		//
		//	dp[k] = cnt(n, k) * good * powers[n * (n - k)] * powers[n * (n - k)];
		//}

		//for (int k: inclusiveRange(n)) {
		//	dp[k] *= fact[n] / fact[k] / fact[n - k];
		//}
		//
		//Z res;
		//for (int k: inclusiveRange(rk, n)) {
		//	res += (k % 2 == rk % 2 ? 1 : -1) * fact[n - rk] / fact[k - rk] / fact[n - k];
		//}
		//out << res << "\n";
		//out << all / cnt(rk) << endl;


	}
};


int main() {
	std::ios_base::sync_with_stdio(false);
	TaskH solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(nullptr);
	out << std::fixed;
	out.precision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5012