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

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

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

i.s = e
e.u = b
e.w = k
b.u = k
b.w = e
k.u = b
k.w = e
j.s = e
assert b.u.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

i.s = e
e.u = b
e.w = k
b.u = k
b.w = e
k.u = b
k.w = e
j.s = e
assert b.u.u.w.txt == "e"