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

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

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

m = A("m")
h = B("h")
a = C("a")
g = A("g")
n = C("n")
e = A("e")
l = A("l")
d = A("d")
f = A("f")

m.o = g
m.v = a
h.w = n
h.v = d
a.r = h
a.x = n
a.u = d
g.o = e
g.v = n
n.r = h
n.x = a
n.u = e
e.o = m
e.v = a
l.o = e
l.v = n
d.o = l
d.v = a
f.o = l
f.v = a
assert f.o.v.u.o.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.v: C = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
a = C("a")
g = A("g")
n = C("n")
e = A("e")
l = A("l")
d = A("d")
f = A("f")

m.o = g
m.v = a
h.w = n
h.v = d
a.r = h
a.x = n
a.u = d
g.o = e
g.v = n
n.r = h
n.x = a
n.u = e
e.o = m
e.v = a
l.o = e
l.v = n
d.o = l
d.v = a
f.o = l
f.v = a
assert f.o.v.u.o.v.u.txt == "d"