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

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

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

g = A("g")
c = B("c")
k = C("k")

g.o = c
g.p = c
g.t = k
c.z = k
c.x = g
k.z = g
k.y = g
k.v = c
assert g.t.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: C = None
        self.p: B = None
        self.txt = txt

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

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

g = A("g")
c = B("c")
k = C("k")

g.o = c
g.p = c
g.t = k
c.z = k
c.x = g
k.z = g
k.y = g
k.v = c
assert g.t.v.x.txt == "g"