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

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

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

k = A("k")
a = B("a")
d = C("d")
f = C("f")
n = A("n")

k.t = a
a.o = k
d.q = k
d.s = a
f.q = k
f.s = a
n.t = a
assert d.q.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

k = A("k")
a = B("a")
d = C("d")
f = C("f")
n = A("n")

k.t = a
a.o = k
d.q = k
d.s = a
f.q = k
f.s = a
n.t = a
assert d.q.t.o.t.txt == "a"