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

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

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

b = A("b")
k = B("k")
n = C("n")
h = A("h")
e = C("e")
g = B("g")
d = A("d")
j = C("j")

b.p = d
k.v = b
k.w = h
k.z = g
n.p = e
n.z = h
h.p = b
e.p = n
e.z = d
g.v = h
g.w = h
g.z = k
d.p = h
j.p = n
j.z = b
assert g.v.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

b = A("b")
k = B("k")
n = C("n")
h = A("h")
e = C("e")
g = B("g")
d = A("d")
j = C("j")

b.p = d
k.v = b
k.w = h
k.z = g
n.p = e
n.z = h
h.p = b
e.p = n
e.z = d
g.v = h
g.w = h
g.z = k
d.p = h
j.p = n
j.z = b
assert g.v.p.p.p.p.p.p.txt == "h"