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

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

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

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

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

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

l.x = k
l.s = d
k.w = j
j.w = h
h.w = k
g.x = k
g.s = d
a.x = j
a.s = g
e.x = h
e.s = d
d.x = h
d.s = e
assert a.s.s.x.w.w.w.w.w.txt == "j"