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

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

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.r: D = None
        self.v: D = None
        self.txt = txt

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

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

e = A("e")
i = B("i")
l = C("l")
b = D("b")
g = E("g")
n = D("n")

e.p = g
e.q = b
i.w = e
l.x = g
l.r = b
l.v = b
b.p = l
b.w = g
g.z = n
n.p = l
n.w = g
assert i.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.q: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.r: D = None
        self.v: D = None
        self.txt = txt

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

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

e = A("e")
i = B("i")
l = C("l")
b = D("b")
g = E("g")
n = D("n")

e.p = g
e.q = b
i.w = e
l.x = g
l.r = b
l.v = b
b.p = l
b.w = g
g.z = n
n.p = l
n.w = g
assert i.w.q.w.txt == "g"