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

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

k = A("k")
i = B("i")
a = B("a")
l = A("l")
c = A("c")

k.x = c
k.w = c
i.u = k
i.x = l
a.u = k
a.x = c
l.x = c
l.w = k
c.x = k
c.w = l
assert l.w.x.x.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.w: A = None
        self.txt = txt

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

k = A("k")
i = B("i")
a = B("a")
l = A("l")
c = A("c")

k.x = c
k.w = c
i.u = k
i.x = l
a.u = k
a.x = c
l.x = c
l.w = k
c.x = k
c.w = l
assert l.w.x.x.w.w.txt == "l"