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

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

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

h = A("h")
e = B("e")
k = C("k")
l = A("l")
g = B("g")
j = A("j")
c = A("c")
a = C("a")
b = B("b")
f = C("f")

h.v = j
e.p = a
e.w = k
k.z = e
k.r = b
l.v = j
g.p = f
g.w = k
j.v = l
c.v = l
a.z = g
a.r = e
b.p = a
b.w = a
f.z = g
f.r = g
assert a.r.p.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
k = C("k")
l = A("l")
g = B("g")
j = A("j")
c = A("c")
a = C("a")
b = B("b")
f = C("f")

h.v = j
e.p = a
e.w = k
k.z = e
k.r = b
l.v = j
g.p = f
g.w = k
j.v = l
c.v = l
a.z = g
a.r = e
b.p = a
b.w = a
f.z = g
f.r = g
assert a.r.p.z.p.txt == "f"