Company: Infosys
Difficulty: medium
You are given an integer N , an array A of length N , and an array B of length N . You have N blocks of 1 bits with sizes A[0 … N-1] , and N blocks of 0 bits with sizes B[0 … N-1] . You must arrange these blocks so that no two adjacent blocks have the same bit value. Among all possible valid arrangements, find the maximum possible number obtained by interpreting the resulting binary string as a decimal integer. Print the result modulo 10 9 + 7 . Notes All blocks in A and B must be used exactly once. Blocks must strictly alternate between 0 and 1. The arrangement may start with either block type. The objective is to maximize the decimal value of the final binary string (the modulo is applied only when printing). Input Format N A[0] ... A[N-1] B[0] ... B[N-1] The first line contains an integer N . Each of the next N lines contains an integer A[i] . Each of the following N lines contains an integer B[i] . Output Format Print a single integer — the maximum value modulo