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

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

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

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

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

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

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

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

f.v = h
f.w = h
f.u = g
d.u = g
d.p = g
d.t = e
k.r = l
h.v = e
h.u = g
h.w = f
a.v = f
a.w = f
a.u = g
l.u = k
l.t = a
l.p = g
g.r = l
e.v = f
e.u = k
e.w = h
m.u = g
m.p = g
m.t = f
assert g.r.p.r.u.r.p.r.p.txt == "g"