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

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

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

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

f.v = m
h.p = k
l.y = a
l.u = j
l.q = f
k.v = f
e.p = f
d.y = a
d.u = l
d.q = m
a.p = f
j.y = a
j.u = l
j.q = k
m.v = f
assert h.p.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

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

f.v = m
h.p = k
l.y = a
l.u = j
l.q = f
k.v = f
e.p = f
d.y = a
d.u = l
d.q = m
a.p = f
j.y = a
j.u = l
j.q = k
m.v = f
assert h.p.v.v.v.v.v.txt == "f"