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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: A = None
        self.u: B = None
        self.w: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: C = None
        self.z: A = None
        self.x: B = None
        self.txt = txt

a = A("a")
h = B("h")
k = C("k")
g = D("g")
d = B("d")
n = B("n")
f = C("f")

a.p = d
a.t = h
h.t = g
h.z = a
h.u = n
h.w = f
k.z = d
g.t = f
g.u = k
g.z = a
g.x = n
d.t = g
d.z = a
d.u = n
d.w = k
n.t = g
n.z = a
n.u = d
n.w = f
f.z = h
assert d.t.x.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: A = None
        self.u: B = None
        self.w: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: C = None
        self.z: A = None
        self.x: B = None
        self.txt = txt

a = A("a")
h = B("h")
k = C("k")
g = D("g")
d = B("d")
n = B("n")
f = C("f")

a.p = d
a.t = h
h.t = g
h.z = a
h.u = n
h.w = f
k.z = d
g.t = f
g.u = k
g.z = a
g.x = n
d.t = g
d.z = a
d.u = n
d.w = k
n.t = g
n.z = a
n.u = d
n.w = f
f.z = h
assert d.t.x.w.z.txt == "h"