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

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

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

f = A("f")
a = B("a")
e = C("e")
m = A("m")
i = C("i")
g = B("g")
n = C("n")

f.o = m
f.r = m
f.v = i
a.t = g
a.u = e
a.s = i
e.p = g
e.s = n
m.o = f
m.r = f
m.v = e
i.p = a
i.s = e
g.t = a
g.u = e
g.s = e
n.p = g
n.s = i
assert m.o.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.v: C = None
        self.txt = txt

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

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

f = A("f")
a = B("a")
e = C("e")
m = A("m")
i = C("i")
g = B("g")
n = C("n")

f.o = m
f.r = m
f.v = i
a.t = g
a.u = e
a.s = i
e.p = g
e.s = n
m.o = f
m.r = f
m.v = e
i.p = a
i.s = e
g.t = a
g.u = e
g.s = e
n.p = g
n.s = i
assert m.o.o.v.txt == "e"