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

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

c = A("c")
l = B("l")
j = A("j")
g = B("g")
b = B("b")
d = A("d")
k = B("k")
e = A("e")

c.z = b
l.s = c
l.r = g
j.z = b
g.s = d
g.r = k
b.s = d
b.r = l
d.z = g
k.s = e
k.r = l
e.z = l
assert b.s.z.r.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

c = A("c")
l = B("l")
j = A("j")
g = B("g")
b = B("b")
d = A("d")
k = B("k")
e = A("e")

c.z = b
l.s = c
l.r = g
j.z = b
g.s = d
g.r = k
b.s = d
b.r = l
d.z = g
k.s = e
k.r = l
e.z = l
assert b.s.z.r.r.s.txt == "c"