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

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

d = A("d")
g = B("g")
n = A("n")
k = A("k")
a = B("a")
j = A("j")
m = B("m")

d.x = g
d.s = m
g.u = m
n.x = g
n.s = g
k.x = g
k.s = g
a.u = g
j.x = g
j.s = g
m.u = g
assert j.x.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: B = None
        self.txt = txt

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

d = A("d")
g = B("g")
n = A("n")
k = A("k")
a = B("a")
j = A("j")
m = B("m")

d.x = g
d.s = m
g.u = m
n.x = g
n.s = g
k.x = g
k.s = g
a.u = g
j.x = g
j.s = g
m.u = g
assert j.x.u.u.u.u.u.txt == "m"