MATNUM - runtime error SIGABRT

Hello, I have problem with SIGABRT error in MATNUM problem. I checked some solutions on google but code still doesn’t work. My compiler on PC doesn’t show any error so I can’t check exactly what’s going on.

#include <iostream>

#include <string>

int main()

{

    int p0{}, p1{}, q{}, T{}, z{1};

    long long int n{}, summary{};

    std::cin >> T;

    for(int i = 1; i<=T; i++)

    {

        std::cin >> p0 >> p1 >> q >> n;

        long long int* tab = new long long int[n];

        tab[0] = p0;

        tab[1] = p1;

        for(int y = 2; y<=(n-1); y++) 

            tab[y] = ((4*tab[y-1]+tab[y-2])%q);

        for(int x = (n-1); x>=0; x--)

        {

            summary = summary + (tab[x]*z);

            z*=10;

        }

        if((summary%q)==0)

            std::cout << "YES\n";

        else

            std::cout << "NO\n";

        delete [] tab;

        summary = 0;

        z = 1;

    }

    return 0;

}