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

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

c = A("c")
h = B("h")
m = A("m")
d = B("d")
a = B("a")
n = B("n")
e = A("e")
j = B("j")

c.u = e
c.z = j
h.s = c
h.v = j
m.u = c
m.z = j
d.s = e
d.v = j
a.s = e
a.v = h
n.s = e
n.v = h
e.u = m
e.z = n
j.s = c
j.v = h
assert d.v.s.z.s.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: B = None
        self.txt = txt

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

c = A("c")
h = B("h")
m = A("m")
d = B("d")
a = B("a")
n = B("n")
e = A("e")
j = B("j")

c.u = e
c.z = j
h.s = c
h.v = j
m.u = c
m.z = j
d.s = e
d.v = j
a.s = e
a.v = h
n.s = e
n.v = h
e.u = m
e.z = n
j.s = c
j.v = h
assert d.v.s.z.s.u.u.txt == "m"