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

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

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

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

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

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

k.s = d
k.x = l
j.z = i
j.s = a
d.z = m
d.s = l
e.z = h
e.s = d
i.s = f
i.x = a
h.s = a
h.x = j
m.s = a
m.x = a
l.z = m
l.s = f
f.z = m
f.s = d
a.z = k
a.s = j
assert j.s.s.z.s.s.s.txt == "l"