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

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

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

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

j.y = a
n.t = k
n.r = g
a.u = n
a.z = n
a.o = j
g.u = n
g.z = k
g.o = j
k.t = n
k.r = a
assert k.t.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

j.y = a
n.t = k
n.r = g
a.u = n
a.z = n
a.o = j
g.u = n
g.z = k
g.o = j
k.t = n
k.r = a
assert k.t.r.z.txt == "k"