There are N walls in the hall of the King's palace, numbered by integers from 1 to N. The King asks the Royal Painter to paint each wall in one of three colors (red, green, or blue). Additionally, the King gives M orders.
Every order has the following form: given two walls, a_i and b_i, and two colors, x_i and y_i, the order dictates that, if the wall a_i is painted with color x_i and the wall b_i is painted with color y_i, the Royal Painter has to be executed.
Your task is to find a number of ways to paint the walls so that the Royal Painter will not be executed.
The first line of the input contains two integers N and M (1≤N≤22, 1≤M≤9⋅N⋅(N−1)/2): the number of walls and the number of orders, respectively.
Each of the following M lines describes one King's order and contains an integer a_i, a letter x_i, an integer b_i, and a letter y_i, separated by single spaces (1≤a_i<b_i≤N, x_i and y_i are letters from 'R', 'G', and 'B', denoting the red, green, and blue colors, respectively). You may assume that all M orders are pairwise distinct (no two orders have the exact same effect).
Print one integer: the number of ways to paint the walls so that the Royal Painter will not be executed.