結果

問題 No.3170 [Cherry 7th Tune KY] Even if you could say "See you ..."
ユーザー 👑 p-adic
提出日時 2024-03-11 08:09:21
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 545 ms / 4,000 ms
コード長 36,695 bytes
コンパイル時間 10,839 ms
コンパイル使用メモリ 237,840 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-11 23:05:01
合計ジャッジ時間 18,192 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

// 入力制約チェック
#ifndef INCLUDE_MODE
  #define INCLUDE_MODE
  // #define REACTIVE
  // #define USE_GETLINE
#endif

#ifdef INCLUDE_MAIN

inline void Solve()
{
  CEXPR( ll , bound_P , 3e5 ); CIN_ASSERT( P , 2 , bound_P );
  FOR( i , 2 , P ){
    assert( P % i != 0 );
    if( i * i > P ){
      break;
    }
  }
  using U = QuotientRing<ll>;
  using M = TwoByTwoMatrix<U>;
  U::SetStaticModulo( &P );
  CIN_ASSERT( A11 , 0 , P - 1 );
  CIN_ASSERT( A12 , 0 , P - 1 );
  CIN_ASSERT( A21 , 0 , P - 1 );
  CIN_ASSERT( A22 , 0 , P - 1 );
  CIN_ASSERT( B11 , 0 , P - 1 );
  CIN_ASSERT( B12 , 0 , P - 1 );
  CIN_ASSERT( B21 , 0 , P - 1 );
  CIN_ASSERT( B22 , 0 , P - 1 );
  M A( A11 , A12 , A21 , A22 );
  M B( B11 , B12 , B21 , B22 );
  M E( 1 , 0 , 0 , 1 );
  if( B == E ){
    CERR( "Solved at" , __LINE__ );
    RETURN( 0 );
  }
  U det_A = A.det();
  U det_B = B.det();
  if( ( det_A == 0 ) != ( det_B == 0 ) ){
    CERR( "Solved at" , __LINE__ );
    RETURN( -1 );
  }
  ll ord_A = det_A == 0 ? -2 : -1;
  M power_A = A;
  FOREQ( n , 1 , P ){
    if( power_A == B ){
      CERR( "Solved at" , __LINE__ );
      RETURN( n );
    }
    if( ord_A == -1 && power_A == E ){
      ord_A = n;
      CERR( "ord_A =" , n );
    }
    power_A *= A;
  }
  if( ord_A != -1 ){
    // ord_A > 0の場合は位数がP以下なのでP乗までで冪乗が全探策可能。
    // ord_A = -2の場合はdet_A = 0なので非正則だが、
    // 対角化可能ならばtrがFpに属すのでP-1乗まで、対角化不可能ならP乗までで
    // 羃乗が全探索可能。
    // 従っていずれの場合も羃乗がP乗までで全探索可能。
    RETURN( -1 );
  }
  // ここから先はord_A = -1つまりdet_A != 0かつ位数がPより大きい。
  // #GL_2(F_P) = P^4 - ( P^2 + P - 1 ) * P = P^4 - P^3 - P^2 + P
  // = P(P-1)(P^2 - 1) = P(P-1)^2(P+1)
  // で位数は対角化可能ならばP^2-1の約数、対角化不可能ならP(P^2-1)の約数。
  // 従ってNはP(P^2-1)未満。N mod P,N mod P-1,N mod P+1を調べる。
  auto Power = [&]( const M& mat , ll e ){
    M answer = E;
    M power = mat;
    while( e > 0 ){
      ( e & 1 ) == 1 ? answer *= power : answer;
      power *= power;
      e >>= 1;
    }
    return answer;
  };
  ll mod[3] = { P * ( P - 1 ) , ( P - 1 ) * ( P + 1 ) , P * ( P + 1 ) };
  M A_P[3];
  M B_P[3];
  int ord_A_P[3] = {-1,-1,-1};
  ll e[3] = {-1,-1,-1};
  // A^N=BならばA^{(N mod (ord_A_P[i]))(P(P^2-1)/ord_A_P[i])}=B^{P(P^2-1)/ord_A_P[i]}
  // なのでN mod ord_A_P[i]の候補が調べられる。
  FOR( i , 0 , 3 ){
    A_P[i] = Power( A , mod[i] );
    B_P[i] = Power( B , mod[i] );
    power_A = E;
    FOREQ( n , 0 , P + 1 ){
      if( e[i] == -1 && power_A == B_P[i] ){
	// N mod ord_A_P[i] = e[i]
	e[i] = n;
      }
      if( n > 0 && power_A == E ){
	ord_A_P[i] = n;
	break;
      }
      power_A *= A_P[i];
    }
    if( e[i] == -1 ){
      CERR( "Solved at" , __LINE__ , "i =" , i );
      RETURN( -1 );
    }
    if( ord_A_P[i] == -1 ){
      while( 1 ){
	COUT( "Error:" , i );
	CERR( P , A11 , A12 , A21 , A22 , B11 , B12 , B21 , B22 );
      }
    }
    CERR( "( P(P^1-1)/ord_A_P[" , i , "] , ord_A_P[" , i , "] , e[" , i , "] ) = (" , P*(P*P-1)/ord_A_P[i] , "," , ord_A_P[i] , "," , e[i] , ")" );
  }
  // 中国剰余定理によりN mod lcm(ord_A_O[i])_iを求められる。
  ll lcm = LCM( ll( ord_A_P[0] ) , ll( ord_A_P[1] ) );
  ll x = ChineseRemainderTheorem( ll( ord_A_P[0] ) , ll( e[0] ) , ll( ord_A_P[1] ) , ll( e[1] ) );
  if( x == -1 ){
    CERR( "Solved at" , __LINE__ );
    RETURN( -1 );
  }
  x = ChineseRemainderTheorem( lcm , x , ll( ord_A_P[2] ) , ll( e[2] ) );
  if( x == -1 ){
    CERR( "Solved at" , __LINE__ );
    RETURN( -1 );
  }
  lcm = LCM( lcm , ll( ord_A_P[2] ) );
  // N mod ord_A_P[i] = e[i]となるNをP(P^2 - 1)以下で全探策。
  power_A = Power( A , x );
  M A_lcm = Power( A , lcm );
  ll N = x;
  while( N <= P * ( P * P - 1 ) ){
    if( power_A == B ){
      CERR( "Solved at" , __LINE__ );
      RETURN( N );
    }
    N += lcm;
    power_A *= A_lcm;
  }
  CERR( "Solved at" , __LINE__ );
  RETURN( -1 );
}
REPEAT_MAIN(5);

#else // INCLUDE_MAIN

#ifdef INCLUDE_LIBRARY

// https://github.com/p-adic/cpp
// VVV ライブラリは以下に挿入する。

template <typename INT>
INT GCD( const INT& b_0 , const INT& b_1 )
{

  INT a_0 = abs( b_0 );
  INT a_1 = abs( b_1 );

  while( a_1 != 0 ){

    swap( a_0 %= a_1 , a_1 );

  }

  return a_0;

}

template <typename INT> inline INT LCM( const INT& b_0 , const INT& b_1 ) { return ( b_0 == 0 && b_1 == 0 ) ? 0 : ( b_0 / GCD( b_0 , b_1 ) ) * b_1; }

template <typename INT>
INT PartitionOfUnity( const INT& b_0 , const INT& b_1 , INT& u_0 ,  INT& u_1 )
{

  INT a[2][2] = { { 1 , 0 } , { 0 , 1 } };
  INT b[2] = { b_0 , b_1 };

  for( int i = 0 ; i < 2 ; i++ ){

    if( b[i] < 0 ){

      a[i][i] = -1;
      b[i] *= -1;

    }

  }
  
  int i_0 = ( b_0 >= b_1 ? 0 : 1 );
  int i_1 = 1 - i_0;

  while( b[i_1] != 0 ){

    INT& b_i_0 = b[i_0];
    const INT& b_i_1 = b[i_1];
    INT ( &a_i_0 )[2] = a[i_0];
    const INT ( &a_i_1 )[2] = a[i_1];
    const INT q = b_i_0 / b_i_1;
    a_i_0[i_0] -= q * a_i_1[i_0];
    a_i_0[i_1] -= q * a_i_1[i_1];
    b_i_0 -= q * b_i_1;
    swap( i_0 , i_1 );

  }

  INT ( &a_i_0 )[2] = a[i_0];
  u_0 = move( a_i_0[0] );
  u_1 = move( a_i_0[1] );
  return move( b[i_0] );

}

template <typename INT>
INT ChineseRemainderTheorem( const INT& b_0 , const INT& c_0 , const INT& b_1 , const INT& c_1 )
{

  INT u_0 , u_1;
  const INT gcd = PartitionOfUnity( b_0 , b_1 , u_0 , u_1 );
  const INT c = c_0 % gcd;

  if( c_1 % gcd != c ){

    return -1;

  }
  
  const INT lcm = ( b_0 / gcd ) * b_1;
  u_0 *= ( c_1 - c ) / gcd;
  Residue( u_0 , lcm );
  u_1 *= ( c_0 - c ) / gcd;
  u_1 = ( u_1 >= 0 ? u_1 % lcm : lcm - ( - u_1 - 1 ) % lcm - 1 );
  return ( c + u_0 * b_0 + u_1 * b_1 ) % lcm;

}

#define SFINAE_FOR_MATRIX( DEFAULT ) typename Arg,enable_if_t<is_constructible<T,Arg>::value>* DEFAULT

template <typename T>
class TwoByTwoMatrix
{
  
private:
  T m_M00;
  T m_M01;
  T m_M10;
  T m_M11;

public:
  inline constexpr TwoByTwoMatrix( const T& M00 , const T& M01 , const T& M10 , const T& M11 ) noexcept;
  inline constexpr TwoByTwoMatrix( T&& M00 , T&& M01 , T&& M10 , T&& M11 ) noexcept;
  inline constexpr TwoByTwoMatrix( const T& n = T() ) noexcept;
  template <SFINAE_FOR_MATRIX( = nullptr )> inline constexpr TwoByTwoMatrix( const Arg& n ) noexcept;
  inline constexpr TwoByTwoMatrix( const TwoByTwoMatrix<T>& mat ) noexcept;
  inline constexpr TwoByTwoMatrix( TwoByTwoMatrix<T>&& mat ) noexcept;
  
  inline constexpr TwoByTwoMatrix<T>& operator=( const TwoByTwoMatrix<T>& mat ) noexcept;
  inline constexpr TwoByTwoMatrix<T>& operator=( TwoByTwoMatrix<T>&& mat ) noexcept;
  inline TwoByTwoMatrix<T>& operator+=( const TwoByTwoMatrix<T>& mat ) noexcept;
  inline TwoByTwoMatrix<T>& operator-=( const TwoByTwoMatrix<T>& mat ) noexcept;
  inline TwoByTwoMatrix<T>& operator*=( const TwoByTwoMatrix<T>& mat ) noexcept;
  inline constexpr TwoByTwoMatrix<T>& operator*=( const T& scalar ) noexcept;
  template <SFINAE_FOR_MATRIX( = nullptr )> inline constexpr TwoByTwoMatrix<T>& operator*=( const Arg& scalar ) noexcept;
  inline TwoByTwoMatrix<T>& operator/=( const TwoByTwoMatrix<T>& mat );
  inline TwoByTwoMatrix<T>& operator/=( const T& scalar );
  template <SFINAE_FOR_MATRIX( = nullptr )> inline constexpr TwoByTwoMatrix<T>& operator/=( const Arg& scalar );
  inline TwoByTwoMatrix<T>& operator%=( const T& scalar );
  template <SFINAE_FOR_MATRIX( = nullptr )> inline constexpr TwoByTwoMatrix<T>& operator%=( const Arg& scalar );

  inline TwoByTwoMatrix<T>& Invert();

  inline constexpr bool operator==( const TwoByTwoMatrix<T>& mat ) const noexcept;
  inline constexpr bool operator!=( const TwoByTwoMatrix<T>& mat ) const noexcept;

  inline TwoByTwoMatrix<T> operator*( const TwoByTwoMatrix<T>& mat ) const noexcept;
  // inline TwoByOneMatrix<T> operator*( const TwoByOneMatrix<T>& mat ) const noexcept;
  inline TwoByTwoMatrix<T> operator/( const TwoByTwoMatrix<T>& mat ) const;
  inline constexpr TwoByTwoMatrix<T> Square() const noexcept;

  inline constexpr T det() const noexcept;
  inline constexpr const T& GetEntry( const uint& y , const uint& x ) const noexcept;
  inline constexpr T& RefEntry( const uint& y , const uint& x ) noexcept;
  
};

template <typename T> inline TwoByTwoMatrix<T> operator+( const TwoByTwoMatrix<T>& mat1 , const TwoByTwoMatrix<T>& mat2 ) noexcept;
template <typename T> inline TwoByTwoMatrix<T> operator-( const TwoByTwoMatrix<T>& mat1 , const TwoByTwoMatrix<T>& mat2 ) noexcept;
template <typename T> inline constexpr TwoByTwoMatrix<T> operator*( const T& scalar , const TwoByTwoMatrix<T>& mat ) noexcept;
template <typename T , SFINAE_FOR_MATRIX( = nullptr )> inline constexpr TwoByTwoMatrix<T> operator*( const Arg& scalar , const TwoByTwoMatrix<T>& mat ) noexcept;
template <typename T> inline constexpr TwoByTwoMatrix<T> operator*( const TwoByTwoMatrix<T>& mat , const T& scalar ) noexcept;
template <typename T , SFINAE_FOR_MATRIX( = nullptr )> inline constexpr TwoByTwoMatrix<T> operator*( const TwoByTwoMatrix<T>& mat , const T& scalar ) noexcept;
template <typename T> inline TwoByTwoMatrix<T> operator/( const TwoByTwoMatrix<T>& mat , const T& scalar );
template <typename T , SFINAE_FOR_MATRIX( = nullptr )> inline TwoByTwoMatrix<T> operator/( const TwoByTwoMatrix<T>& mat , const Arg& scalar );
template <typename T> inline TwoByTwoMatrix<T> operator%( const TwoByTwoMatrix<T>& mat , const T& scalar );
template <typename T , SFINAE_FOR_MATRIX( = nullptr )> inline TwoByTwoMatrix<T> operator%( const TwoByTwoMatrix<T>& mat , const Arg& scalar );

template <typename T> inline constexpr TwoByTwoMatrix<T>::TwoByTwoMatrix( const T& M00 , const T& M01 , const T& M10 , const T& M11 ) noexcept : m_M00( M00 ) , m_M01( M01 ) , m_M10( M10 ) , m_M11( M11 ) {}
template <typename T> inline constexpr TwoByTwoMatrix<T>::TwoByTwoMatrix( T&& M00 , T&& M01 , T&& M10 , T&& M11 ) noexcept : m_M00( move( M00 ) ) , m_M01( move( M01 ) ) , m_M10( move( M10 ) ) , m_M11( move( M11 ) ) {}
template <typename T> inline constexpr TwoByTwoMatrix<T>::TwoByTwoMatrix( const T& n ) noexcept : m_M00( n ) , m_M01() , m_M10() , m_M11( n ) {}
template <typename T> template <SFINAE_FOR_MATRIX()> inline constexpr TwoByTwoMatrix<T>::TwoByTwoMatrix( const Arg& n ) noexcept : TwoByTwoMatrix( T( n ) ) {}
template <typename T> inline constexpr TwoByTwoMatrix<T>::TwoByTwoMatrix( const TwoByTwoMatrix<T>& mat ) noexcept : m_M00( mat.m_M00 ) , m_M01( mat.m_M01 ) , m_M10( mat.m_M10 ) , m_M11( mat.m_M11 ) {}
template <typename T> inline constexpr TwoByTwoMatrix<T>::TwoByTwoMatrix( TwoByTwoMatrix<T>&& mat ) noexcept : m_M00( move( mat.m_M00 ) ) , m_M01( move( mat.m_M01 ) ) , m_M10( move( mat.m_M10 ) ) , m_M11( move( mat.m_M11 ) ) {}


template <typename T> inline constexpr TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator=( const TwoByTwoMatrix<T>& mat ) noexcept { if( &mat != this ){ m_M00 = mat.m_M00; m_M01 = mat.m_M01; m_M10 = mat.m_M10; m_M11 = mat.m_M11; } return *this; }

template <typename T> inline constexpr TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator=( TwoByTwoMatrix<T>&& mat ) noexcept { m_M00 = move( mat.m_M00 ); m_M01 = move( mat.m_M01 ); m_M10 = move( mat.m_M10 ); m_M11 = move( mat.m_M11 ); return *this; }

template <typename T> inline TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator+=( const TwoByTwoMatrix<T>& mat ) noexcept { m_M00 += mat.m_M00; m_M01 += mat.m_M01; m_M10 += mat.m_M10; m_M11 += mat.m_M11; return *this; }
template <typename T> inline TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator-=( const TwoByTwoMatrix<T>& mat ) noexcept { m_M00 -= mat.m_M00; m_M01 -= mat.m_M01; m_M10 -= mat.m_M10; m_M11 -= mat.m_M11; return *this; }
template <typename T> inline TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator*=( const TwoByTwoMatrix<T>& mat ) noexcept { return operator=( *this * mat ); }
template <typename T> inline constexpr TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator*=( const T& scalar ) noexcept { m_M00 *= scalar; m_M01 *= scalar; m_M10 *= scalar; m_M11 *= scalar; return *this; }
template <typename T> template <SFINAE_FOR_MATRIX()> inline constexpr TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator*=( const Arg& scalar ) noexcept { return operator*=( T( scalar ) ); }
template <typename T> inline TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator/=( const TwoByTwoMatrix<T>& mat ) { return operator=( *this / mat ); }
template <typename T> inline TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator/=( const T& scalar ) { return operator*=( T( 1 ) / scalar ); }
template <typename T> template <SFINAE_FOR_MATRIX()> inline constexpr TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator/=( const Arg& scalar ) { return operator/=( T( scalar ) ); }
template <typename T> inline TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator%=( const T& scalar ) { m_M00 %= scalar; m_M01 %= scalar; m_M10 %= scalar; m_M11 %= scalar; return *this; }
template <typename T> template <SFINAE_FOR_MATRIX()> inline constexpr TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::operator%=( const Arg& scalar ) { return operator%=( T( scalar ) ); }

template <typename T> inline TwoByTwoMatrix<T>& TwoByTwoMatrix<T>::Invert() { const T det_inv{ T( 1 ) / ( m_M00 * m_M11 - m_M01 * m_M10 ) }; swap( m_M00 , m_M11 ); m_M01 = T() - m_M01; m_M10 = T() - m_M10; return operator*=( det_inv ); }

template <typename T> inline constexpr bool TwoByTwoMatrix<T>::operator==( const TwoByTwoMatrix<T>& mat ) const noexcept { return m_M00 == mat.m_M00 && m_M01 == mat.m_M01 && m_M10 == mat.m_M10 && m_M11 == mat.m_M11; }
template <typename T> inline constexpr bool TwoByTwoMatrix<T>::operator!=( const TwoByTwoMatrix<T>& mat ) const noexcept { return !( *this == mat ); }

template <typename T> inline TwoByTwoMatrix<T> TwoByTwoMatrix<T>::operator*( const TwoByTwoMatrix<T>& mat ) const noexcept { return TwoByTwoMatrix<T>( m_M00 * mat.m_M00 + m_M01 * mat.m_M10 , m_M00 * mat.m_M01 + m_M01 * mat.m_M11 , m_M10 * mat.m_M00 + m_M11 * mat.m_M10 , m_M10 * mat.m_M01 + m_M11 * mat.m_M11 ); }

// template <typename T> inline TwoByOneMatrix<T> TwoByTwoMatrix<T>::operator*( const TwoByOneMatrix<T>& mat ) const noexcept { return TwoByOneMatrix<T>( m_M00 * mat.m_M0 + m_M01 * mat.m_M1 , m_M10 * mat.m_M0 + m_M11 * mat.m_M1 ); }

template <typename T> inline TwoByTwoMatrix<T> TwoByTwoMatrix<T>::operator/( const TwoByTwoMatrix<T>& mat ) const { const T det_inv{ T( 1 ) / ( mat.m_M00 * mat.m_M11 - mat.m_M01 * mat.m_M10 ) }; return TwoByTwoMatrix<T>( ( m_M00 * mat.m_M11 - m_M01 * mat.m_M10 ) * det_inv , ( m_M01 * mat.m_M00 - m_M00 * mat.m_M01 ) * det_inv , ( m_M10 * mat.m_M11 - m_M11 * mat.m_M10 ) * det_inv , ( m_M11 * mat.m_M00 - m_M10 * mat.m_M01 ) * det_inv ); }

template <typename T> inline constexpr TwoByTwoMatrix<T> TwoByTwoMatrix<T>::Square() const noexcept { return TwoByTwoMatrix<T>( m_M00 * m_M00 + m_M01 * m_M10 , ( m_M00 + m_M11 ) * m_M01 , m_M10 * ( m_M00 + m_M11 ) , m_M10 * m_M01 + m_M11 * m_M11 ); }

template <typename T> inline constexpr T TwoByTwoMatrix<T>::det() const noexcept { return m_M00 * m_M11 - m_M01 * m_M10; }
template <typename T> inline constexpr const T& TwoByTwoMatrix<T>::GetEntry( const uint& y , const uint& x ) const noexcept { return y == 0 ? x == 0 ? m_M00 : m_M01 : x == 0 ? m_M10 : m_M11; }
template <typename T> inline constexpr T& TwoByTwoMatrix<T>::RefEntry( const uint& y , const uint& x ) noexcept { return y == 0 ? x == 0 ? m_M00 : m_M01 : x == 0 ? m_M10 : m_M11; }

template <typename T> inline TwoByTwoMatrix<T> operator+( const TwoByTwoMatrix<T>& mat1 , const TwoByTwoMatrix<T>& mat2 ) noexcept { return move( TwoByTwoMatrix<T>( mat1 ) += mat2 ); }
template <typename T> inline TwoByTwoMatrix<T> operator-( const TwoByTwoMatrix<T>& mat1 , const TwoByTwoMatrix<T>& mat2 ) noexcept { return move( TwoByTwoMatrix<T>( mat1 ) -= mat2 ); }
template <typename T> inline constexpr TwoByTwoMatrix<T> operator*( const T& scalar , const TwoByTwoMatrix<T>& mat ) noexcept { return move( TwoByTwoMatrix<T>( mat ) *= scalar ); }
template <typename T , SFINAE_FOR_MATRIX()> inline constexpr TwoByTwoMatrix<T> operator*( const Arg& scalar , const TwoByTwoMatrix<T>& mat ) noexcept { return T( scalar ) * mat; }
template <typename T> inline constexpr TwoByTwoMatrix<T> operator*( const TwoByTwoMatrix<T>& mat , const T& scalar ) noexcept { return move( TwoByTwoMatrix<T>( mat ) *= scalar ); }
template <typename T , SFINAE_FOR_MATRIX()> inline constexpr TwoByTwoMatrix<T> operator*( const TwoByTwoMatrix<T>& mat , const Arg& scalar ) noexcept { return mat * T( scalar ); }
template <typename T> inline TwoByTwoMatrix<T> operator/( const TwoByTwoMatrix<T>& mat , const T& scalar ) { return move( TwoByTwoMatrix<T>( mat ) /= scalar ); }
template <typename T , SFINAE_FOR_MATRIX()> inline TwoByTwoMatrix<T> operator/( const TwoByTwoMatrix<T>& mat , const Arg& scalar ) { return mat / T( scalar ); }
template <typename T> inline TwoByTwoMatrix<T> operator%( const TwoByTwoMatrix<T>& mat , const T& scalar ) { return move( TwoByTwoMatrix<T>( mat ) %= scalar ); }
template <typename T , SFINAE_FOR_MATRIX()> inline TwoByTwoMatrix<T> operator%( const TwoByTwoMatrix<T>& mat , const Arg& scalar ) { return mat % T( scalar ); }

template <typename INT>
class QuotientRing
{

protected:
  INT m_n;
  const INT* m_p_M;
  static const INT* g_p_M;

public:
  inline QuotientRing() noexcept;
  inline QuotientRing( const INT& n , const INT* const& p_M = g_p_M ) noexcept;
  inline QuotientRing( const QuotientRing<INT>& n ) noexcept;

  inline QuotientRing<INT>& operator+=( const QuotientRing<INT>& n ) noexcept;
  template <typename T> inline QuotientRing<INT>& operator+=( const T& n ) noexcept;
  // operator<が定義されていても負の数は正に直さず剰余を取ることに注意。
  inline QuotientRing<INT>& operator-=( const QuotientRing<INT>& n ) noexcept;
  template <typename T> inline QuotientRing<INT>& operator-=( const T& n ) noexcept;
  inline QuotientRing<INT>& operator*=( const QuotientRing<INT>& n ) noexcept;
  template <typename T> inline QuotientRing<INT>& operator*=( const T& n ) noexcept;
  // *m_p_Mが素数でかつnの逆元が存在する場合のみサポート。
  inline QuotientRing<INT>& operator/=( const QuotientRing<INT>& n );
  template <typename T> inline QuotientRing<INT>& operator/=( const T& n );

  // m_nの正負やm_p_Mの一致込みの等号。
  inline bool operator==( const QuotientRing<INT>& n ) const noexcept;
  // m_nの正負込みの等号。
  template <typename T> inline bool operator==( const T& n ) const noexcept;
  template <typename T> inline bool operator!=( const T& n ) const noexcept;

  template <typename T> inline QuotientRing<INT> operator+( const T& n1 ) const noexcept;
  inline QuotientRing<INT> operator-() const noexcept;
  template <typename T> inline QuotientRing<INT> operator-( const T& n1 ) const noexcept;
  template <typename T> inline QuotientRing<INT> operator*( const T& n1 ) const noexcept;
  // *m_p_Mが素数でかつn1の逆元が存在する場合のみサポート。
  template <typename T> inline QuotientRing<INT> operator/( const T& n1 ) const;

  inline const INT& Represent() const noexcept;
  inline const INT& GetModulo() const noexcept;
  inline void SetModulo( const INT* const& p_M = nullptr ) noexcept;
  static inline const INT& GetStaticModulo() noexcept;
  static inline void SetStaticModulo( const INT* const& p_M ) noexcept;

  template <typename T> static QuotientRing<INT> Power( const QuotientRing<INT>& n , T exponent );
  // *m_p_Mが素数でかつnの逆元が存在する場合のみサポート。
  static QuotientRing<INT> Inverse( const QuotientRing<INT>& n );
  
};

template <typename INT , typename T> inline QuotientRing<INT> Power( const QuotientRing<INT>& n , T exponent );
// *(n.m_p_M)が素数でかつnの逆元が存在する場合のみサポート。
template <typename INT> inline QuotientRing<INT> Inverse( const QuotientRing<INT>& n );

template <typename INT , class Traits> inline basic_istream<char,Traits>& operator>>( basic_istream<char,Traits>& is , QuotientRing<INT>& n );
template <typename INT , class Traits> inline basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os , const QuotientRing<INT>& n );

template <typename INT> const INT* QuotientRing<INT>::g_p_M = nullptr;
template <typename INT> inline QuotientRing<INT>::QuotientRing() noexcept : m_n() , m_p_M( g_p_M ) {}
template <typename INT> inline QuotientRing<INT>::QuotientRing( const INT& n , const INT* const& p_M ) noexcept : m_n( p_M == nullptr ? n : n % *p_M ) , m_p_M( p_M ) {}
template <typename INT> inline QuotientRing<INT>::QuotientRing( const QuotientRing<INT>& n ) noexcept : m_n( n.m_n ) , m_p_M( n.m_p_M ) {}

template <typename INT> inline QuotientRing<INT>& QuotientRing<INT>::operator+=( const QuotientRing<INT>& n ) noexcept { if( m_p_M == nullptr ){ m_p_M = n.m_p_M; } m_n += n.m_n; if( m_p_M != nullptr ){ m_n %= *m_p_M; } return *this; }
template <typename INT> template <typename T> inline QuotientRing<INT>& QuotientRing<INT>::operator+=( const T& n ) noexcept { m_p_M == nullptr ? m_n += n : ( m_n += n % *m_p_M ) %= *m_p_M; return *this; }
template <typename INT> inline QuotientRing<INT>& QuotientRing<INT>::operator-=( const QuotientRing<INT>& n ) noexcept { if( m_p_M == nullptr ){ m_p_M = n.m_p_M; } m_n -= n.m_n; if( m_p_M != nullptr ){ m_n %= *m_p_M; } return *this; }
template <typename INT> template <typename T> inline QuotientRing<INT>& QuotientRing<INT>::operator-=( const T& n ) noexcept { m_p_M == nullptr ? m_n -= n : ( m_n -= n % *m_p_M ) %= *m_p_M; return *this; }
template <typename INT> inline QuotientRing<INT>& QuotientRing<INT>::operator*=( const QuotientRing<INT>& n ) noexcept { if( m_p_M == nullptr ){ m_p_M = n.m_p_M; } m_n *= n.m_n; if( m_p_M != nullptr ){ m_n %= *m_p_M; } return *this; }
template <typename INT> template <typename T> inline QuotientRing<INT>& QuotientRing<INT>::operator*=( const T& n ) noexcept { m_p_M == nullptr ? m_n *= n : ( m_n *= n % *m_p_M ) %= *m_p_M; return *this; }
template <typename INT> inline QuotientRing<INT>& QuotientRing<INT>::operator/=( const QuotientRing<INT>& n ) { if( m_p_M == nullptr ){ if( n.m_p_M == nullptr ){ assert( n.m_n != 0 ); m_n /= n.m_n; return *this; } else { m_p_M = n.m_p_M; } } return operator*=( Inverse( QuotientRing<INT>( n.m_n , m_p_M ) ) ); }
template <typename INT> template <typename T> inline QuotientRing<INT>& QuotientRing<INT>::operator/=( const T& n ) { if( m_p_M == nullptr ){ assert( n.m_n != 0 ); m_n /= n.m_n; return *this; } return operator*=( Inverse( Q( n.m_n , m_p_M ) ) ); }

template <typename INT> inline bool QuotientRing<INT>::operator==( const QuotientRing<INT>& n ) const noexcept { return m_p_M == n.m_p_M && m_n == n.m_n; }
template <typename INT> template <typename T> inline bool QuotientRing<INT>::operator==( const T& n ) const noexcept { return m_n == n; }
template <typename INT> template <typename T> inline bool QuotientRing<INT>::operator!=( const T& n ) const noexcept { return !operator==( n ); }

template <typename INT> template<typename T> inline QuotientRing<INT> QuotientRing<INT>::operator+( const T& n ) const noexcept { return QuotientRing<INT>( *this ).operator+=( n ); }
template <typename INT> inline QuotientRing<INT> QuotientRing<INT>::operator-() const noexcept { return QuotientRing<INT>( -m_n , m_p_M ); }
template <typename INT> template<typename T> inline QuotientRing<INT> QuotientRing<INT>::operator-( const T& n ) const noexcept { return QuotientRing<INT>( *this ).operator-=( n ); }
template <typename INT> template<typename T> inline QuotientRing<INT> QuotientRing<INT>::operator*( const T& n ) const noexcept { return QuotientRing<INT>( *this ).operator*=( n ); }
template <typename INT> template<typename T> inline QuotientRing<INT> QuotientRing<INT>::operator/( const T& n ) const { return QuotientRing<INT>( *this ).operator/=( n ); }
  
template <typename INT> inline const INT& QuotientRing<INT>::Represent() const noexcept { return m_n; }
template <typename INT> inline const INT& QuotientRing<INT>::GetModulo() const noexcept { static const INT zero{ 0 }; return m_p_M == nullptr ? zero : *m_p_M; }
template <typename INT> inline void QuotientRing<INT>::SetModulo( const INT* const& p_M ) noexcept { m_p_M = p_M; if( m_p_M != nullptr ){ m_n %= *m_p_M; } }
template <typename INT> inline const INT& QuotientRing<INT>::GetStaticModulo() noexcept { static const INT zero{ 0 }; return g_p_M == nullptr ? zero : *g_p_M; }
template <typename INT> inline void QuotientRing<INT>::SetStaticModulo( const INT* const& p_M ) noexcept { g_p_M = p_M; }

template <typename INT> template <typename T>
QuotientRing<INT> QuotientRing<INT>::Power( const QuotientRing<INT>& n , T exponent )
{

  QuotientRing<INT> answer{ 1 , n.m_p_M };
  QuotientRing<INT> power{ n };

  while( exponent != 0 ){

    if( exponent % 2 == 1 ){

      answer *= power;

    }

    power *= power;
    exponent /= 2;

  }

  return answer;

}

template <typename INT> inline QuotientRing<INT> QuotientRing<INT>::Inverse( const QuotientRing<INT>& n ) { assert( n.m_p_M != nullptr ); return Power( n , *( n.m_p_M ) - 2 ); }

template <typename INT , typename T> inline QuotientRing<INT> Power( const QuotientRing<INT>& n , T exponent ) { return QuotientRing<INT>::template Power<T>( n , exponent ); }
template <typename INT> inline QuotientRing<INT> Inverse( const QuotientRing<INT>& n ) { return QuotientRing<INT>::Inverse( n ); }

template <typename INT , class Traits> inline basic_istream<char,Traits>& operator>>( basic_istream<char,Traits>& is , QuotientRing<INT>& n ) { INT m; is >> m; n = m; return is; }
template <typename INT , class Traits> inline basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os , const QuotientRing<INT>& n ) { return os << n.Represent(); }

// AAA ライブラリは以上に挿入する。

#define INCLUDE_MAIN
#include __FILE__

#else // INCLUDE_LIBRARY

#ifdef DEBUG
  #define _GLIBCXX_DEBUG
  #define SIGNAL signal( SIGABRT , &AlertAbort );
  #define ASSERT( A , MIN , MAX ) CERR( "ASSERTチェック: " , ( MIN ) , ( ( MIN ) <= A ? "<=" : ">" ) , A , ( A <= ( MAX ) ? "<=" : ">" ) , ( MAX ) ); assert( ( MIN ) <= A && A <= ( MAX ) )
  #define CERR( ... ) VariadicCout( cerr , __VA_ARGS__ ) << endl
  #define COUT( ... ) VariadicCout( cout << "出力: " , __VA_ARGS__ ) << endl
  #define CERR_A( A , N ) OUTPUT_ARRAY( cerr , A , N ) << endl
  #define COUT_A( A , N ) cout << "出力: "; OUTPUT_ARRAY( cout , A , N ) << endl
  #define CERR_ITR( A ) OUTPUT_ITR( cerr , A ) << endl
  #define COUT_ITR( A ) cout << "出力: "; OUTPUT_ITR( cout , A ) << endl
#else
  #pragma GCC optimize ( "O3" )
  #pragma GCC optimize ( "unroll-loops" )
  #pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" )
  #define SIGNAL 
  #define ASSERT( A , MIN , MAX ) assert( ( MIN ) <= A && A <= ( MAX ) )
  #define CERR( ... ) 
  #define COUT( ... ) VariadicCout( cout , __VA_ARGS__ ) << ENDL
  #define CERR_A( A , N ) 
  #define COUT_A( A , N ) OUTPUT_ARRAY( cout , A , N ) << ENDL
  #define CERR_ITR( A ) 
  #define COUT_ITR( A ) OUTPUT_ITR( cout , A ) << ENDL
#endif
#ifdef REACTIVE
  #define ENDL endl
#else
  #define ENDL "\n"
#endif
#ifdef USE_GETLINE
  #define SET_LL( A ) { GETLINE( A ## _str ); A = stoll( A ## _str ); }
  #define GETLINE_SEPARATE( SEPARATOR , ... ) string __VA_ARGS__; VariadicGetline( cin , SEPARATOR , __VA_ARGS__ )
  #define GETLINE( ... ) GETLINE_SEPARATE( '\n' , __VA_ARGS__ )
#else
  #define SET_LL( A ) cin >> A
  #define CIN( LL , ... ) LL __VA_ARGS__; VariadicCin( cin , __VA_ARGS__ )
  #define SET_A( A , N ) FOR( VARIABLE_FOR_SET_A , 0 , N ){ cin >> A[VARIABLE_FOR_SET_A]; }
  #define CIN_A( LL , A , N ) vector<LL> A( N ); SET_A( A , N );
#endif
#include <bits/stdc++.h>
using namespace std;
#define REPEAT_MAIN( BOUND ) int main(){ ios_base::sync_with_stdio( false ); cin.tie( nullptr ); SIGNAL; CEXPR( int , bound_test_case_num , BOUND ); int test_case_num = 1; if constexpr( bound_test_case_num > 1 ){ CERR( "テストケースの個数を入力してください。" ); SET_ASSERT( test_case_num , 1 , bound_test_case_num ); } REPEAT( test_case_num ){ if constexpr( bound_test_case_num > 1 ){ CERR( "testcase " , VARIABLE_FOR_REPEAT_test_case_num , ":" ); } Solve(); CERR( "" ); } CHECK_REDUNDANT_INPUT; }
#define START_WATCH chrono::system_clock::time_point watch = chrono::system_clock::now()
#define CURRENT_TIME static_cast<double>( chrono::duration_cast<chrono::microseconds>( chrono::system_clock::now() - watch ).count() / 1000.0 )
#define CHECK_WATCH( TL_MS ) ( CURRENT_TIME < TL_MS - 100.0 )
#define CEXPR( LL , BOUND , VALUE ) constexpr LL BOUND = VALUE
#define SET_ASSERT( A , MIN , MAX ) SET_LL( A ); ASSERT( A , MIN , MAX )
#define SET_A_ASSERT( A , N , MIN , MAX ) FOR( VARIABLE_FOR_SET_A , 0 , N ){ SET_ASSERT( A[VARIABLE_FOR_SET_A] , MIN , MAX ); }
#define CIN_ASSERT( A , MIN , MAX ) decldecay_t( MAX ) A; SET_ASSERT( A , MIN , MAX )
#define CIN_A_ASSERT( A , N , MIN , MAX ) vector<decldecay_t( MAX )> A( N ); SET_A_ASSERT( A , N , MIN , MAX )
#define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( decldecay_t( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ )
#define FOREQ( VAR , INITIAL , FINAL ) for( decldecay_t( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ )
#define FOREQINV( VAR , INITIAL , FINAL ) for( decldecay_t( INITIAL ) VAR = INITIAL ; VAR + 1 > FINAL ; VAR -- )
#define AUTO_ITR( ARRAY ) auto itr_ ## ARRAY = ARRAY .begin() , end_ ## ARRAY = ARRAY .end()
#define FOR_ITR( ARRAY ) for( AUTO_ITR( ARRAY ) , itr = itr_ ## ARRAY ; itr_ ## ARRAY != end_ ## ARRAY ; itr_ ## ARRAY ++ , itr++ )
#define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT_ ## HOW_MANY_TIMES , 0 , HOW_MANY_TIMES )
#define SET_PRECISION( DECIMAL_DIGITS ) cout << fixed << setprecision( DECIMAL_DIGITS )
#define OUTPUT_ARRAY( OS , A , N ) FOR( VARIABLE_FOR_OUTPUT_ARRAY , 0 , N ){ OS << A[VARIABLE_FOR_OUTPUT_ARRAY] << (VARIABLE_FOR_OUTPUT_ARRAY==N-1?"":" "); } OS
#define OUTPUT_ITR( OS , A ) { auto ITERATOR_FOR_OUTPUT_ITR = A.begin() , END_FOR_OUTPUT_ITR = A.end(); bool VARIABLE_FOR_OUTPUT_ITR = ITERATOR_FOR_COUT_ITR != END_FOR_COUT_ITR; while( VARIABLE_FOR_OUTPUT_ITR ){ OS << *ITERATOR_FOR_COUT_ITR; ( VARIABLE_FOR_OUTPUT_ITR = ++ITERATOR_FOR_COUT_ITR != END_FOR_COUT_ITR ) ? OS : OS << " "; } } OS
#define RETURN( ... ) COUT( __VA_ARGS__ ); return

// 型のエイリアス
#define decldecay_t( VAR ) decay_t<decltype( VAR )>
template <typename F , typename...Args> using ret_t = decltype( declval<F>()( declval<Args>()... ) );
template <typename T> using inner_t = typename T::type;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using lld = __float128;
template <typename INT> using T2 = pair<INT,INT>;
template <typename INT> using T3 = tuple<INT,INT,INT>;
template <typename INT> using T4 = tuple<INT,INT,INT,INT>;
using path = pair<int,ll>;

// 入出力用
template <class Traits> inline basic_istream<char,Traits>& VariadicCin( basic_istream<char,Traits>& is ) { return is; }
template <class Traits , typename Arg , typename... ARGS> inline basic_istream<char,Traits>& VariadicCin( basic_istream<char,Traits>& is , Arg& arg , ARGS&... args ) { return VariadicCin( is >> arg , args... ); }
template <class Traits> inline basic_istream<char,Traits>& VariadicGetline( basic_istream<char,Traits>& is , const char& separator ) { return is; }
template <class Traits , typename Arg , typename... ARGS> inline basic_istream<char,Traits>& VariadicGetline( basic_istream<char,Traits>& is , const char& separator , Arg& arg , ARGS&... args ) { return VariadicGetline( getline( is , arg , separator ) , separator , args... ); }
template <class Traits , typename Arg> inline basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os , const vector<Arg>& arg ) { auto begin = arg.begin() , end = arg.end(); auto itr = begin; while( itr != end ){ ( itr == begin ? os : os << " " ) << *itr; itr++; } return os; }
template <class Traits , typename Arg1 , typename Arg2> inline basic_ostream<char,Traits>& operator<<( basic_ostream<char,Traits>& os , const pair<Arg1,Arg2>& arg ) { return os << arg.first << " " << arg.second; }
template <class Traits , typename Arg> inline basic_ostream<char,Traits>& VariadicCout( basic_ostream<char,Traits>& os , const Arg& arg ) { return os << arg; }
template <class Traits , typename Arg1 , typename Arg2 , typename... ARGS> inline basic_ostream<char,Traits>& VariadicCout( basic_ostream<char,Traits>& os , const Arg1& arg1 , const Arg2& arg2 , const ARGS&... args ) { return VariadicCout( os << arg1 << " " , arg2 , args... ); }

// 算術用
template <typename T> constexpr T PositiveBaseResidue( const T& a , const T& p ){ return a >= 0 ? a % p : p - 1 - ( ( - ( a + 1 ) ) % p ); }
template <typename T> constexpr T Residue( const T& a , const T& p ){ return PositiveBaseResidue( a , p < 0 ? -p : p ); }

// デバッグ用
#ifdef DEBUG
  inline void AlertAbort( int n ) { CERR( "abort関数が呼ばれました。assertマクロのメッセージが出力されていない場合はオーバーフローの有無を確認をしてください。" ); }
  void AutoCheck( bool& auto_checked );
#endif

// 入力フォーマットチェック用
// 1行中の変数の個数をSEPARATOR区切りで確認
#define GETLINE_COUNT( S , VARIABLE_NUMBER , SEPARATOR ) GETLINE( S ); int VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S = 0; int VARIABLE_FOR_SIZE_FOR_GETLINE_FOR_ ## S  = S.size(); { int size = S.size(); int count = 0; for( int i = 0 ; i < size ; i++ ){ if( S.substr( i , 1 ) == SEPARATOR ){ count++; } } assert( count + 1 == VARIABLE_NUMBER ); }
// 余計な入力の有無を確認
#ifdef DEBUG
  #define CHECK_REDUNDANT_INPUT 
#else
  #ifdef USE_GETLINE
    #define CHECK_REDUNDANT_INPUT string VARIABLE_FOR_CHECK_REDUNDANT_INPUT = ""; getline( cin , VARIABLE_FOR_CHECK_REDUNDANT_INPUT ); assert( VARIABLE_FOR_CHECK_REDUNDANT_INPUT == "" ); assert( ! cin )
  #else
    #define CHECK_REDUNDANT_INPUT string VARIABLE_FOR_CHECK_REDUNDANT_INPUT = ""; cin >> VARIABLE_FOR_CHECK_REDUNDANT_INPUT; assert( VARIABLE_FOR_CHECK_REDUNDANT_INPUT == "" ); assert( ! cin )
  #endif
#endif
// |N| <= BOUNDを満たすNをSから構築
#define STOI( S , N , BOUND ) decldecay_t( BOUND ) N = 0; { bool VARIABLE_FOR_POSITIVITY_FOR_GETLINE = true; assert( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S < VARIABLE_FOR_SIZE_FOR_GETLINE_FOR_ ## S ); if( S.substr( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S , 1 ) == "-" ){ VARIABLE_FOR_POSITIVITY_FOR_GETLINE = false; VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S ++; assert( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S < VARIABLE_FOR_SIZE_FOR_GETLINE_FOR_ ## S ); } assert( S.substr( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S , 1 ) != " " ); string VARIABLE_FOR_LETTER_FOR_GETLINE{}; int VARIABLE_FOR_DIGIT_FOR_GETLINE{}; while( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S < VARIABLE_FOR_SIZE_FOR_GETLINE_FOR_ ## S ? ( VARIABLE_FOR_LETTER_FOR_GETLINE = S.substr( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S , 1 ) ) != " " : false ){ VARIABLE_FOR_DIGIT_FOR_GETLINE = stoi( VARIABLE_FOR_LETTER_FOR_GETLINE ); assert( N < BOUND / 10 ? true : N == BOUND / 10 && VARIABLE_FOR_DIGIT_FOR_GETLINE <= BOUND % 10 ); N = N * 10 + VARIABLE_FOR_DIGIT_FOR_GETLINE; VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S ++; } if( ! VARIABLE_FOR_POSITIVITY_FOR_GETLINE ){ N *= -1; } if( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S < VARIABLE_FOR_SIZE_FOR_GETLINE_FOR_ ## S ){ VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S ++; } }
// SをSEPARATORで区切りTを構築
#define SEPARATE( S , T , SEPARATOR ) string T{}; { assert( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S < VARIABLE_FOR_SIZE_FOR_GETLINE_FOR_ ## S ); int VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S_prev = VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S; assert( S.substr( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S , 1 ) != SEPARATOR ); string VARIABLE_FOR_LETTER_FOR_GETLINE{}; while( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S < VARIABLE_FOR_SIZE_FOR_GETLINE_FOR_ ## S ? ( VARIABLE_FOR_LETTER_FOR_GETLINE = S.substr( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S , 1 ) ) != SEPARATOR : false ){ VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S ++; } T = S.substr( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S_prev , VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S - VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S_prev ); if( VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S < VARIABLE_FOR_SIZE_FOR_GETLINE_FOR_ ## S ){ VARIABLE_FOR_INDEX_FOR_GETLINE_FOR_ ## S ++; } }

#define INCLUDE_LIBRARY
#include __FILE__

#endif // INCLUDE_LIBRARY

#endif // INCLUDE_MAIN
0