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

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

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

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

h = A("h")
l = B("l")
d = C("d")
e = D("e")
k = A("k")
c = B("c")
f = D("f")

h.p = k
h.z = k
l.w = c
d.r = k
d.q = h
e.v = d
e.t = d
e.p = k
k.p = h
k.z = h
c.w = l
f.v = d
f.t = d
f.p = k
assert l.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: A = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
d = C("d")
e = D("e")
k = A("k")
c = B("c")
f = D("f")

h.p = k
h.z = k
l.w = c
d.r = k
d.q = h
e.v = d
e.t = d
e.p = k
k.p = h
k.z = h
c.w = l
f.v = d
f.t = d
f.p = k
assert l.w.w.w.w.w.txt == "c"