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

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

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

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

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

j = A("j")
d = B("d")
l = C("l")
b = D("b")
n = E("n")
m = A("m")
h = B("h")

j.p = m
d.q = n
d.s = n
d.z = m
l.u = h
b.v = m
b.y = h
n.w = m
n.r = m
n.q = j
n.x = b
n.p = d
m.p = j
h.q = n
h.s = n
h.z = m
assert b.v.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

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

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

j = A("j")
d = B("d")
l = C("l")
b = D("b")
n = E("n")
m = A("m")
h = B("h")

j.p = m
d.q = n
d.s = n
d.z = m
l.u = h
b.v = m
b.y = h
n.w = m
n.r = m
n.q = j
n.x = b
n.p = d
m.p = j
h.q = n
h.s = n
h.z = m
assert b.v.p.p.p.txt == "j"