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

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

a = A("a")
m = B("m")
i = A("i")
j = A("j")
h = A("h")
d = A("d")
c = A("c")
f = B("f")

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

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

a = A("a")
m = B("m")
i = A("i")
j = A("j")
h = A("h")
d = A("d")
c = A("c")
f = B("f")

a.u = c
a.s = f
m.o = j
m.v = d
i.u = a
i.s = f
j.u = c
j.s = m
h.u = i
h.s = m
d.u = i
d.s = m
c.u = a
c.s = m
f.o = h
f.v = d
assert c.s.o.u.s.o.s.o.s.txt == "m"