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

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

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

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

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

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

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

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

l.p = k
l.v = d
d.v = l
d.r = b
b.y = g
b.p = d
k.y = c
k.p = m
m.v = h
m.r = k
g.v = a
g.r = k
c.v = l
c.r = k
h.p = b
h.v = c
a.p = b
a.v = g
assert h.v.r.y.v.v.v.txt == "l"