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

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

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

d = A("d")
b = B("b")
h = C("h")
k = A("k")
m = B("m")
f = B("f")
e = C("e")

d.y = e
d.q = h
b.u = m
b.z = k
b.p = d
h.v = e
h.z = k
h.t = b
k.y = h
k.q = h
m.u = f
m.z = d
m.p = d
f.u = b
f.z = d
f.p = k
e.v = h
e.z = k
e.t = b
assert f.p.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: C = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
h = C("h")
k = A("k")
m = B("m")
f = B("f")
e = C("e")

d.y = e
d.q = h
b.u = m
b.z = k
b.p = d
h.v = e
h.z = k
h.t = b
k.y = h
k.q = h
m.u = f
m.z = d
m.p = d
f.u = b
f.z = d
f.p = k
e.v = h
e.z = k
e.t = b
assert f.p.y.z.txt == "k"