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

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

n = A("n")
j = B("j")
l = A("l")
i = A("i")
k = A("k")
g = B("g")
d = A("d")
c = A("c")

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

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

n = A("n")
j = B("j")
l = A("l")
i = A("i")
k = A("k")
g = B("g")
d = A("d")
c = A("c")

n.s = g
n.y = j
j.z = g
j.r = g
l.s = g
l.y = g
i.s = g
i.y = g
k.s = j
k.y = j
g.z = j
g.r = j
d.s = j
d.y = j
c.s = j
c.y = j
assert g.z.r.z.r.r.r.r.r.txt == "g"