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

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

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

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

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

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

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