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

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

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

a = A("a")
e = B("e")
g = C("g")
i = B("i")
m = B("m")
j = A("j")

a.w = j
e.o = m
e.y = a
g.s = i
g.r = e
g.t = a
i.o = e
i.y = j
m.o = i
m.y = a
j.w = a
assert g.t.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

a = A("a")
e = B("e")
g = C("g")
i = B("i")
m = B("m")
j = A("j")

a.w = j
e.o = m
e.y = a
g.s = i
g.r = e
g.t = a
i.o = e
i.y = j
m.o = i
m.y = a
j.w = a
assert g.t.w.w.w.w.txt == "a"