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

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

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

k = A("k")
g = B("g")
m = C("m")
l = C("l")
d = A("d")

k.t = l
k.q = l
k.o = g
g.u = k
m.z = g
m.u = g
m.r = k
l.z = g
l.u = g
l.r = k
d.t = m
d.q = m
d.o = g
assert k.o.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.q: C = None
        self.o: B = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
m = C("m")
l = C("l")
d = A("d")

k.t = l
k.q = l
k.o = g
g.u = k
m.z = g
m.u = g
m.r = k
l.z = g
l.u = g
l.r = k
d.t = m
d.q = m
d.o = g
assert k.o.u.t.txt == "l"