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

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

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: C = None
        self.o: B = None
        self.txt = txt

n = A("n")
m = B("m")
a = C("a")
b = C("b")
k = B("k")
g = A("g")

n.s = m
n.v = g
n.y = g
m.z = b
m.y = k
a.x = b
a.q = b
a.o = m
b.x = a
b.q = a
b.o = k
k.z = a
k.y = m
g.s = k
g.v = n
g.y = n
assert g.v.y.s.z.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.v: A = None
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: C = None
        self.o: B = None
        self.txt = txt

n = A("n")
m = B("m")
a = C("a")
b = C("b")
k = B("k")
g = A("g")

n.s = m
n.v = g
n.y = g
m.z = b
m.y = k
a.x = b
a.q = b
a.o = m
b.x = a
b.q = a
b.o = k
k.z = a
k.y = m
g.s = k
g.v = n
g.y = n
assert g.v.y.s.z.o.y.txt == "k"