Submit | All submissions | Best solutions | Back to list |

## HS11LFSR - Linear Feedback Shift Register |

Given a Fibonacci linear feedback shift register (LFSR) please emulate its behaviour.

### Input

First *t*<100, the number of test cases. In each of the following *t* lines:

1<*l*<=1024 - the length of the register (the number of bits),

*seed* - the initial value of the LFSR in binary format,

0<*p*<*l* - the number of taps (bits which influence the input),

*p*_{1},*p*_{2},...,*p _{p}* - the taps in increasing order in decimal format, 0<

*p*<=

_{i}*l*.

### Output

Please output, byte by byte, the first 128 output bits of the register in hexadecimal format.

### Example

Input:2 3 010 2 2 3 5 00110 3 1 3 5Output:A7 D3 E9 74 3A 9D 4E A7 D3 E9 74 3A 9D 4E A7 D3 85 9B C2 4D E1 A6 70 53 B8 29 DC 14 6E 0A 37 85

### Scoring

By solving this problem you score 10 points.

Added by: | kuszi |

Date: | 2012-01-19 |

Time limit: | 0.306s |

Source limit: | 50000B |

Memory limit: | 1536MB |

Cluster: | Cube (Intel G860) |

Languages: | All except: ASM32-GCC ASM64 MAWK GAWK BC C-CLANG CPP14-CLANG CPP14 COBOL COFFEE D-DMD D-CLANG DART ELIXIR FANTOM FORTH GOSU GRV JS-MONKEY KTLN NIM NODEJS OBJC OBJC-CLANG OCT PICO PROLOG PYPY PY_NBC R RACKET RUST CHICKEN SED SQLITE SWIFT UNLAMBDA VB.NET |

Resource: | High School Programming League |