You are given a number. Your task is to check if there exists a permutation of the digits of this number which is divisible by 4.

**Input: **

The first line of input contains a single integer **T** denoting the number of test cases. Then **T** test cases follow. Each test case consists of one line. The line consists of a non negative integer **N**. This integer may have leading zeros.

**Output:**

Corresponding to each test case, in a new line, print 1 if such a permutation of this number exists or print 0 if such a permutation doesn't exist.

**Constraints:**

1 ≤ T ≤ 100

0 ≤ N ≤ 10^{200 }

**Example:**

**Input**

3

003

715

123456

**Output**

1

0

1

**Explanation:**

For 003, we have a permutation 300 which is divisible by 4.

For 123456, we have 123564 which is a permutation of 123456 and is divisible by 4.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

narahc321 | 170 |

agness | 163 |

lonecoder | 153 |

2016uec1342 | 142 |

HuHu | 140 |

lonecoder | 1088 |

nikhil_sojan | 1082 |

KshatriyaYash | 1066 |

mazumderrohit8 | 928 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4504 |

Quandray | 4444 |

Login to report an issue on this page.