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

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

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

d = A("d")
a = B("a")
g = C("g")
m = A("m")
l = C("l")
f = B("f")
i = C("i")
n = A("n")
c = B("c")

d.y = f
a.o = l
g.t = l
g.q = f
m.y = f
l.t = g
l.q = c
f.o = i
i.t = l
i.q = a
n.y = f
c.o = g
assert i.t.q.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
g = C("g")
m = A("m")
l = C("l")
f = B("f")
i = C("i")
n = A("n")
c = B("c")

d.y = f
a.o = l
g.t = l
g.q = f
m.y = f
l.t = g
l.q = c
f.o = i
i.t = l
i.q = a
n.y = f
c.o = g
assert i.t.q.o.t.txt == "l"