Answer:
Variable       Where Declared
In Sub1 :
         A        Sub1
         Y        Sub1
         Z        Sub1
         X        Main
In Sub2:
         A        Sub2
         B        Sub2
         Z        Sub2
         Y        Sub1
         X        Main
In Sub3 :
         A        Sub3
         X        Sub3
         W       Sub3
         Y        Main
         Z        Main
Explanation:
In static-scoped languages with nested subprograms, the declaration of a variable is checked with the subprogram, if it is not found, it check within the parent method that called it, it continue until it find a declaration, if no declaration is found, it display an error.
In Sub1, a, y, z is declared there while the declaration of x is found in main.
In Sub2, a, b, z is declared, declaration of y is found in sub1 and declaration of x is found in main.
In Sub3, a, x, w is declared while the declaration of y, z is from the main.