CF461D.Appleman and Complicated Task

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Toastman came up with a very complicated task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?

Given a n×nn×n checkerboard. Each cell of the board has either character 'x', or character 'o', or nothing. How many ways to fill all the empty cells with 'x' or 'o' (each cell must contain only one character in the end) are there, such that for each cell the number of adjacent cells with 'o' will be even? Find the number of ways modulo 10000000071000000007 (109+7)(10^{9}+7) . Two cells of the board are adjacent if they share a side.

输入格式

The first line contains two integers nn , kk ( 1<=n,k<=1051<=n,k<=10^{5} ) — the size of the board, and the number of cells that has characters initially.

Then kk lines follows. The ii -th line contains two integers and a character: aia_{i} , bib_{i} , cic_{i} ( 1<=ai,bi<=n1<=a_{i},b_{i}<=n ; cic_{i} is either 'o' or 'x'). This line means: there is a character cic_{i} in the cell that is located on the intersection of the aia_{i} -th row and bib_{i} -th column. All the given cells are distinct.

Consider that the rows are numbered from 11 to nn from top to bottom. Analogically, the columns are numbered from 11 to nn from left to right.

输出格式

Print a single integer — the answer to the problem.

输入输出样例

  • 输入#1

    3 2
    1 1 x
    2 2 o
    

    输出#1

    2
    
  • 输入#2

    4 3
    2 4 x
    3 4 x
    3 2 x
    

    输出#2

    2
    

说明/提示

In the first example there are two ways:

<br></br> xxo xoo<br></br> xox ooo<br></br> oxx oox<br></br>

首页