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

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

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

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

d = A("d")
j = B("j")
h = C("h")
e = D("e")
n = A("n")
f = C("f")
i = B("i")
k = A("k")
c = B("c")
b = B("b")

d.p = f
d.w = n
d.s = j
j.q = c
j.z = f
j.p = e
j.r = e
h.y = b
h.t = c
h.v = d
e.u = f
e.v = n
n.p = h
n.w = d
n.s = i
f.y = b
f.t = b
f.v = d
i.q = j
i.z = h
i.p = e
i.r = e
k.p = h
k.w = n
k.s = i
c.q = i
c.z = f
c.p = e
c.r = e
b.q = i
b.z = f
b.p = e
b.r = e
assert f.v.s.q.z.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: A = None
        self.s: B = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
h = C("h")
e = D("e")
n = A("n")
f = C("f")
i = B("i")
k = A("k")
c = B("c")
b = B("b")

d.p = f
d.w = n
d.s = j
j.q = c
j.z = f
j.p = e
j.r = e
h.y = b
h.t = c
h.v = d
e.u = f
e.v = n
n.p = h
n.w = d
n.s = i
f.y = b
f.t = b
f.v = d
i.q = j
i.z = h
i.p = e
i.r = e
k.p = h
k.w = n
k.s = i
c.q = i
c.z = f
c.p = e
c.r = e
b.q = i
b.z = f
b.p = e
b.r = e
assert f.v.s.q.z.v.p.txt == "f"