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

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

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

e = A("e")
h = B("h")
f = C("f")
k = A("k")
g = C("g")
n = B("n")

e.v = f
e.o = f
e.r = k
h.r = g
h.o = g
h.v = n
f.y = g
f.z = g
k.v = g
k.o = g
k.r = e
g.y = f
g.z = f
n.r = f
n.o = g
n.v = h
assert f.z.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: A = None
        self.o: C = None
        self.txt = txt

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

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

e = A("e")
h = B("h")
f = C("f")
k = A("k")
g = C("g")
n = B("n")

e.v = f
e.o = f
e.r = k
h.r = g
h.o = g
h.v = n
f.y = g
f.z = g
k.v = g
k.o = g
k.r = e
g.y = f
g.z = f
n.r = f
n.o = g
n.v = h
assert f.z.y.z.txt == "g"