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

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

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

g = A("g")
b = B("b")
j = C("j")
a = B("a")
d = B("d")
i = B("i")
k = C("k")
m = C("m")
c = B("c")
h = A("h")

g.u = i
g.s = m
g.r = b
b.u = a
b.x = h
j.u = m
j.z = g
j.r = g
a.u = d
a.x = h
d.u = a
d.x = h
i.u = c
i.x = h
k.u = m
k.z = g
k.r = g
m.u = k
m.z = g
m.r = h
c.u = d
c.x = h
h.u = a
h.s = j
h.r = b
assert b.u.x.s.z.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: C = None
        self.r: B = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
j = C("j")
a = B("a")
d = B("d")
i = B("i")
k = C("k")
m = C("m")
c = B("c")
h = A("h")

g.u = i
g.s = m
g.r = b
b.u = a
b.x = h
j.u = m
j.z = g
j.r = g
a.u = d
a.x = h
d.u = a
d.x = h
i.u = c
i.x = h
k.u = m
k.z = g
k.r = g
m.u = k
m.z = g
m.r = h
c.u = d
c.x = h
h.u = a
h.s = j
h.r = b
assert b.u.x.s.z.u.x.txt == "h"