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

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

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

a = A("a")
n = B("n")
c = C("c")
j = B("j")
g = C("g")

a.o = n
a.r = j
n.x = a
n.p = c
n.u = j
c.z = a
j.x = a
j.p = c
j.u = n
g.z = a
assert c.z.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.r: B = None
        self.txt = txt

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

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

a = A("a")
n = B("n")
c = C("c")
j = B("j")
g = C("g")

a.o = n
a.r = j
n.x = a
n.p = c
n.u = j
c.z = a
j.x = a
j.p = c
j.u = n
g.z = a
assert c.z.o.x.txt == "a"