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

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

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

a = A("a")
j = B("j")
n = C("n")
b = C("b")
c = A("c")
l = B("l")
g = B("g")
m = B("m")
e = A("e")
k = C("k")

a.z = n
a.s = n
a.y = b
j.u = m
j.r = a
n.y = c
n.u = b
b.y = c
b.u = n
c.z = n
c.y = n
c.s = b
l.u = m
l.r = c
g.u = j
g.r = c
m.u = j
m.r = a
e.z = b
e.s = k
e.y = n
k.y = e
k.u = n
assert m.r.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.s: C = None
        self.y: C = None
        self.txt = txt

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

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

a = A("a")
j = B("j")
n = C("n")
b = C("b")
c = A("c")
l = B("l")
g = B("g")
m = B("m")
e = A("e")
k = C("k")

a.z = n
a.s = n
a.y = b
j.u = m
j.r = a
n.y = c
n.u = b
b.y = c
b.u = n
c.z = n
c.y = n
c.s = b
l.u = m
l.r = c
g.u = j
g.r = c
m.u = j
m.r = a
e.z = b
e.s = k
e.y = n
k.y = e
k.u = n
assert m.r.z.u.txt == "b"