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

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

h = A("h")
j = B("j")
k = B("k")
l = A("l")
i = B("i")
b = B("b")

h.s = b
h.z = k
j.r = k
j.y = b
k.r = b
k.y = b
l.s = b
l.z = k
i.r = b
i.y = j
b.r = i
b.y = k
assert l.s.y.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: B = None
        self.txt = txt

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

h = A("h")
j = B("j")
k = B("k")
l = A("l")
i = B("i")
b = B("b")

h.s = b
h.z = k
j.r = k
j.y = b
k.r = b
k.y = b
l.s = b
l.z = k
i.r = b
i.y = j
b.r = i
b.y = k
assert l.s.y.r.r.r.r.txt == "i"