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

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

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

m = A("m")
d = B("d")
l = C("l")
c = C("c")
a = C("a")
b = B("b")
i = B("i")
k = B("k")
h = A("h")
f = B("f")

m.p = k
m.y = h
m.v = d
d.u = h
d.v = h
l.x = d
l.p = h
l.r = h
c.x = i
c.p = m
c.r = h
a.x = k
a.p = h
a.r = h
b.u = h
b.v = h
i.u = h
i.v = m
k.u = h
k.v = h
h.p = k
h.v = k
h.y = m
f.u = m
f.v = h
assert a.r.y.y.p.u.p.v.p.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: A = None
        self.v: B = None
        self.txt = txt

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

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

m = A("m")
d = B("d")
l = C("l")
c = C("c")
a = C("a")
b = B("b")
i = B("i")
k = B("k")
h = A("h")
f = B("f")

m.p = k
m.y = h
m.v = d
d.u = h
d.v = h
l.x = d
l.p = h
l.r = h
c.x = i
c.p = m
c.r = h
a.x = k
a.p = h
a.r = h
b.u = h
b.v = h
i.u = h
i.v = m
k.u = h
k.v = h
h.p = k
h.v = k
h.y = m
f.u = m
f.v = h
assert a.r.y.y.p.u.p.v.p.u.y.txt == "m"