class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: G = None
        self.y: D = None
        self.w: A = None
        self.z: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: G = None
        self.z: A = None
        self.q: E = None
        self.u: G = None
        self.r: A = None
        self.w: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: D = None
        self.r: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: A = None
        self.r: A = None
        self.t: B = None
        self.x: E = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

g = A("g")
f = B("f")
k = C("k")
i = D("i")
l = E("l")
a = F("a")
b = G("b")
d = G("d")
m = E("m")

g.p = k
f.v = g
f.w = g
f.x = d
f.y = i
f.z = i
k.t = i
k.z = g
i.x = b
i.u = b
i.z = g
i.r = g
i.w = g
i.q = l
l.o = i
l.q = i
l.r = g
a.u = g
a.z = g
a.r = g
a.t = f
a.x = l
b.t = g
d.t = g
m.o = i
m.q = i
m.r = g
assert g.p.z.p.z.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.x: G = None
        self.y: D = None
        self.w: A = None
        self.z: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: G = None
        self.z: A = None
        self.q: E = None
        self.u: G = None
        self.r: A = None
        self.w: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: D = None
        self.r: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: A = None
        self.r: A = None
        self.t: B = None
        self.x: E = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

g = A("g")
f = B("f")
k = C("k")
i = D("i")
l = E("l")
a = F("a")
b = G("b")
d = G("d")
m = E("m")

g.p = k
f.v = g
f.w = g
f.x = d
f.y = i
f.z = i
k.t = i
k.z = g
i.x = b
i.u = b
i.z = g
i.r = g
i.w = g
i.q = l
l.o = i
l.q = i
l.r = g
a.u = g
a.z = g
a.r = g
a.t = f
a.x = l
b.t = g
d.t = g
m.o = i
m.q = i
m.r = g
assert g.p.z.p.z.p.z.txt == "g"