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

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

i = A("i")
e = B("e")
b = B("b")
j = A("j")

i.w = j
e.t = i
e.p = b
b.t = i
b.p = e
j.w = i
assert j.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.t: A = None
        self.p: B = None
        self.txt = txt

i = A("i")
e = B("e")
b = B("b")
j = A("j")

i.w = j
e.t = i
e.p = b
b.t = i
b.p = e
j.w = i
assert j.w.w.w.w.txt == "j"