Color the table
Practice
3 (5 votes)
Math basic
Algorithms
Basic math
Math
Problem
85% Success 598 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a table with \(n\) rows and \(m\) columns. You want to color each unit square of the table with one of the following three colors:

  • Red
  • Blue
  • Black

The condition to color the units is as follows:

  • Each unit square of the table must contain two different colors and each color must occur twice.

Your task is to determine the number of ways you can color the table.

Input format

  • First line: One integer \(T\) denoting the number of test cases
  • Next \(T\) lines: Two space-separated integers \(n\) and \(m\) denoting the rows and columns of the table

Output format

In \(T\) lines, print the answer for each test case that represents the number of ways you can color the table.

Constraints

\(1 \leq T \leq 10^{5}\\ 1 \leq n, m \leq 10^{9}\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
8 votes
Tags:
MathematicsVery-EasyMathematicsMathamatics
Points:10
3 votes
Tags:
Basics of ImplementationMathBasic MathBasic Programming
Points:10
20 votes
Tags:
Basic MathObservationMathematicsC++MathematicsMathematics