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

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

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

j = A("j")
e = B("e")
f = C("f")
k = A("k")
m = A("m")
i = C("i")
c = B("c")

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

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

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

j = A("j")
e = B("e")
f = C("f")
k = A("k")
m = A("m")
i = C("i")
c = B("c")

j.t = e
e.y = j
e.w = c
f.w = i
k.t = e
m.t = e
i.w = f
c.y = k
c.w = e
assert m.t.w.w.txt == "e"