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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: A = None
        self.y: C = None
        self.x: D = None
        self.txt = txt

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

e = A("e")
g = B("g")
f = C("f")
k = D("k")
m = A("m")
h = B("h")
b = A("b")
n = C("n")
j = A("j")

e.p = j
e.u = g
g.t = k
f.q = m
f.w = e
f.y = n
f.x = k
k.r = e
k.z = h
m.p = j
m.u = h
h.t = k
b.p = j
b.u = h
n.q = m
n.w = m
n.y = f
n.x = k
j.p = b
j.u = h
assert h.t.z.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.u: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.w: A = None
        self.y: C = None
        self.x: D = None
        self.txt = txt

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

e = A("e")
g = B("g")
f = C("f")
k = D("k")
m = A("m")
h = B("h")
b = A("b")
n = C("n")
j = A("j")

e.p = j
e.u = g
g.t = k
f.q = m
f.w = e
f.y = n
f.x = k
k.r = e
k.z = h
m.p = j
m.u = h
h.t = k
b.p = j
b.u = h
n.q = m
n.w = m
n.y = f
n.x = k
j.p = b
j.u = h
assert h.t.z.t.z.t.txt == "k"