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

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

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

n = A("n")
h = B("h")
f = C("f")
k = A("k")
j = B("j")
i = C("i")

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

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

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

n = A("n")
h = B("h")
f = C("f")
k = A("k")
j = B("j")
i = C("i")

n.v = h
n.z = i
h.t = n
h.y = n
h.z = f
f.r = i
f.o = i
f.x = k
k.v = j
k.z = f
j.t = k
j.z = i
j.y = n
i.r = f
i.o = f
i.x = k
assert i.x.z.o.r.txt == "f"