Devu and most energetic minion

All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian as well.
After celebrating his birthday, Devu decided to have some adventure and set himself on a secret mission by joining the AVL (AntiVillain League) to fight against bad people. For their new secret mission, Devu wants to recruit the most energetic minion. You know how minions get energy? By eating bananas. The minions travel in a grid B that has bananas in each of its N x N cells. B[x][y] is the energy stored in a banana in row x and column y.
The journey starts from topleft cell (1, 1) and ends at bottomright cell (N, N) by going only either right or down each step (i.e. from a cell (x, y) to either (x, y + 1) or (x + 1, y) only). Initial energy of minion is zero. When a minion with energy e enters a cell (x, y), it eats a banana and its energy becomes e ^ B[x][y], where ^ is the standard bitwiseXOR operator. There are many different ways of completing the journey. Please help the minion to find out a journey with maximum energy so that it can be recruited by Devu. Please output the maximum energy a minion can achieve in some journey
(Bitwise xor operator is denoted by a caret (^) in several programming languages like C, C++, C#, Java, Perl, Ruby and Python. More about it: http://en.wikipedia.org/wiki/Exclusive_or)Input
 There is a single test case.
 First line contains an integer N denoting the number of rows or columns of the grid B.
 Next N lines represent the grid B, where each of these N lines contain N space separated integers. ith line contains N space separated integers denoting ith row of the grid B.
Output
Print a single integer denoting maximum energy a minion can achieve at the end of a rightdown path from (1, 1) to (N, N).
Constraints
 2 ≤ N ≤ 18
 0 ≤ B[i][j] ≤ 10^{9}
Example
Input: 3 1 3 2 3 4 3 5 3 7 Output: 4
Explanation
There are 6 different possible journeys of the minion, and energy at the end of them are  One journey  1 ^ 3 ^ 2 ^ 3 ^ 7 = 4 Four journeys  1 ^ 3 ^ 4 ^ 3 ^ 7 = 2 One journeys  1 ^ 3 ^ 5 ^ 3 ^ 7 = 3 So the maximum energy achieved by a minion is 4.
Author:  flying_ant 
Editorial  http://discuss.codechef.com/problems/XORGRID 
Tags  cook58, flying_ant, mediumhard, tries 
Date Added:  15052015 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 