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

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

k = A("k")
e = B("e")
j = A("j")
m = A("m")
l = B("l")
a = A("a")
d = A("d")

k.x = e
e.w = j
e.t = a
j.x = e
m.x = l
l.w = d
l.t = d
a.x = l
d.x = l
assert a.x.w.x.w.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

k = A("k")
e = B("e")
j = A("j")
m = A("m")
l = B("l")
a = A("a")
d = A("d")

k.x = e
e.w = j
e.t = a
j.x = e
m.x = l
l.w = d
l.t = d
a.x = l
d.x = l
assert a.x.w.x.w.x.w.x.txt == "l"