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

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

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

a = A("a")
i = B("i")
d = C("d")
f = A("f")
b = C("b")
k = C("k")
l = C("l")

a.t = d
a.q = i
i.p = f
i.q = b
i.w = d
d.o = i
f.t = b
f.q = i
b.o = i
k.o = i
l.o = i
assert d.o.w.o.q.o.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.q: B = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
d = C("d")
f = A("f")
b = C("b")
k = C("k")
l = C("l")

a.t = d
a.q = i
i.p = f
i.q = b
i.w = d
d.o = i
f.t = b
f.q = i
b.o = i
k.o = i
l.o = i
assert d.o.w.o.q.o.p.q.txt == "i"