Thanks to Ilya Volchanetskiy for catching a flaw in the pattern generation and for translating into Russian