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

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

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

g = A("g")
j = B("j")
k = C("k")
f = B("f")
l = C("l")
c = A("c")
i = A("i")

g.o = j
j.t = c
k.w = i
f.t = g
l.w = i
c.o = j
i.o = j
assert l.w.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

g = A("g")
j = B("j")
k = C("k")
f = B("f")
l = C("l")
c = A("c")
i = A("i")

g.o = j
j.t = c
k.w = i
f.t = g
l.w = i
c.o = j
i.o = j
assert l.w.o.t.txt == "c"