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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: D = None
        self.q: A = None
        self.p: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

n = A("n")
i = B("i")
k = C("k")
c = D("c")
d = E("d")
g = E("g")
h = B("h")

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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: D = None
        self.q: A = None
        self.p: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

n = A("n")
i = B("i")
k = C("k")
c = D("c")
d = E("d")
g = E("g")
h = B("h")

n.z = h
i.y = n
i.q = n
i.x = c
i.p = g
k.x = n
k.u = n
k.r = i
k.t = i
k.y = c
c.w = n
c.r = d
d.u = g
g.u = d
h.y = n
h.q = n
h.x = c
h.p = d
assert d.u.u.u.u.txt == "d"