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

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

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

g = A("g")
n = B("n")
i = C("i")
j = A("j")
f = B("f")

g.z = n
g.v = i
n.z = i
n.o = f
n.t = j
i.u = j
i.r = j
j.z = n
j.v = i
f.z = i
f.o = n
f.t = j
assert j.z.o.o.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: C = None
        self.txt = txt

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

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

g = A("g")
n = B("n")
i = C("i")
j = A("j")
f = B("f")

g.z = n
g.v = i
n.z = i
n.o = f
n.t = j
i.u = j
i.r = j
j.z = n
j.v = i
f.z = i
f.o = n
f.t = j
assert j.z.o.o.z.r.txt == "j"