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

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

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

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

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

f = A("f")
b = B("b")
n = C("n")
m = D("m")
e = E("e")
g = E("g")

f.p = e
f.w = e
f.z = n
b.z = m
n.r = e
n.y = b
m.y = f
m.x = f
m.z = f
m.r = b
e.q = g
e.z = g
e.y = b
e.w = m
e.p = m
g.q = e
g.z = e
g.y = b
g.w = m
g.p = m
assert n.y.z.r.z.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.w: E = None
        self.z: C = None
        self.txt = txt

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

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

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

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

f = A("f")
b = B("b")
n = C("n")
m = D("m")
e = E("e")
g = E("g")

f.p = e
f.w = e
f.z = n
b.z = m
n.r = e
n.y = b
m.y = f
m.x = f
m.z = f
m.r = b
e.q = g
e.z = g
e.y = b
e.w = m
e.p = m
g.q = e
g.z = e
g.y = b
g.w = m
g.p = m
assert n.y.z.r.z.z.p.txt == "e"