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

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

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

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

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

j = A("j")
d = B("d")
n = C("n")
l = D("l")
g = E("g")
e = C("e")

j.t = g
j.v = g
j.p = n
d.t = n
d.q = j
d.z = l
d.u = l
d.v = e
n.q = d
n.u = g
l.v = g
l.p = j
l.z = d
g.y = e
e.q = d
e.u = g
assert d.u.z.z.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.v: E = None
        self.p: C = None
        self.txt = txt

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

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

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

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

j = A("j")
d = B("d")
n = C("n")
l = D("l")
g = E("g")
e = C("e")

j.t = g
j.v = g
j.p = n
d.t = n
d.q = j
d.z = l
d.u = l
d.v = e
n.q = d
n.u = g
l.v = g
l.p = j
l.z = d
g.y = e
e.q = d
e.u = g
assert d.u.z.z.z.q.txt == "j"