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

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

j = A("j")
e = B("e")
i = A("i")
c = A("c")
a = B("a")

j.w = i
j.o = e
e.t = i
i.w = j
i.o = e
c.w = i
c.o = e
a.t = c
assert j.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: B = None
        self.txt = txt

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

j = A("j")
e = B("e")
i = A("i")
c = A("c")
a = B("a")

j.w = i
j.o = e
e.t = i
i.w = j
i.o = e
c.w = i
c.o = e
a.t = c
assert j.w.w.w.txt == "i"