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

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

g = A("g")
n = B("n")
e = A("e")
i = B("i")
h = A("h")
k = A("k")
j = B("j")
b = B("b")
f = A("f")
m = A("m")

g.u = m
n.s = g
n.z = m
e.u = m
i.s = h
i.z = f
h.u = k
k.u = m
j.s = e
j.z = k
b.s = e
b.z = k
f.u = g
m.u = h
assert j.s.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

g = A("g")
n = B("n")
e = A("e")
i = B("i")
h = A("h")
k = A("k")
j = B("j")
b = B("b")
f = A("f")
m = A("m")

g.u = m
n.s = g
n.z = m
e.u = m
i.s = h
i.z = f
h.u = k
k.u = m
j.s = e
j.z = k
b.s = e
b.z = k
f.u = g
m.u = h
assert j.s.u.u.u.u.u.u.txt == "k"