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

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

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

g = A("g")
m = B("m")
d = C("d")
a = B("a")
i = C("i")
k = B("k")
b = A("b")

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

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

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

g = A("g")
m = B("m")
d = C("d")
a = B("a")
i = C("i")
k = B("k")
b = A("b")

g.p = b
g.r = d
g.u = d
m.t = a
m.w = i
m.z = b
d.p = m
d.q = g
d.t = g
a.t = m
a.w = d
a.z = b
i.p = k
i.q = b
i.t = b
k.t = m
k.w = d
k.z = g
b.p = g
b.r = i
b.u = i
assert a.z.r.p.z.p.txt == "b"