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

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

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

f = A("f")
k = B("k")
a = C("a")
i = B("i")
d = A("d")
h = C("h")
j = B("j")
n = A("n")
l = B("l")

f.o = h
k.t = j
a.w = h
a.t = f
i.t = j
d.o = a
h.w = a
h.t = d
j.t = i
n.o = h
l.t = k
assert a.t.o.t.o.w.w.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

f = A("f")
k = B("k")
a = C("a")
i = B("i")
d = A("d")
h = C("h")
j = B("j")
n = A("n")
l = B("l")

f.o = h
k.t = j
a.w = h
a.t = f
i.t = j
d.o = a
h.w = a
h.t = d
j.t = i
n.o = h
l.t = k
assert a.t.o.t.o.w.w.t.o.t.txt == "d"