class A:
    def __init__(self, txt: str):
        self.y: 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")
d = B("d")
f = A("f")
b = A("b")
k = A("k")
a = A("a")
n = B("n")

i.y = d
d.u = n
d.w = n
f.y = n
b.y = d
k.y = n
a.y = d
n.u = d
n.w = d
assert i.y.u.u.u.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: 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")
d = B("d")
f = A("f")
b = A("b")
k = A("k")
a = A("a")
n = B("n")

i.y = d
d.u = n
d.w = n
f.y = n
b.y = d
k.y = n
a.y = d
n.u = d
n.w = d
assert i.y.u.u.u.w.w.txt == "n"