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

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: E = None
        self.txt = txt

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

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

g.q = e
e.x = m
b.z = g
k.t = e
k.x = m
m.y = b
m.p = b
n.t = e
n.x = m
assert m.y.z.q.x.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: E = None
        self.txt = txt

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

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

g.q = e
e.x = m
b.z = g
k.t = e
k.x = m
m.y = b
m.p = b
n.t = e
n.x = m
assert m.y.z.q.x.p.z.txt == "g"