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

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

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

n = A("n")
m = B("m")
g = C("g")
k = C("k")
d = C("d")
l = A("l")

n.y = m
n.u = k
n.s = l
m.z = n
m.x = n
m.u = l
g.u = k
g.y = n
k.u = g
k.y = n
d.u = k
d.y = l
l.y = m
l.u = d
l.s = n
assert k.u.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: C = None
        self.s: A = None
        self.txt = txt

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

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

n = A("n")
m = B("m")
g = C("g")
k = C("k")
d = C("d")
l = A("l")

n.y = m
n.u = k
n.s = l
m.z = n
m.x = n
m.u = l
g.u = k
g.y = n
k.u = g
k.y = n
d.u = k
d.y = l
l.y = m
l.u = d
l.s = n
assert k.u.y.s.txt == "l"