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

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

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

n = A("n")
e = B("e")
m = C("m")
g = B("g")

n.z = e
e.v = g
e.o = n
e.x = m
m.u = g
g.v = e
g.o = n
g.x = m
assert n.z.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
m = C("m")
g = B("g")

n.z = e
e.v = g
e.o = n
e.x = m
m.u = g
g.v = e
g.o = n
g.x = m
assert n.z.x.u.txt == "g"