class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: C = None
        self.r: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.t: D = None
        self.y: A = None
        self.z: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.o: B = None
        self.t: A = None
        self.q: B = None
        self.txt = txt

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

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

b = A("b")
i = B("i")
c = C("c")
g = D("g")
n = E("n")
m = D("m")

b.o = i
b.r = i
b.t = i
b.p = c
i.p = m
i.t = m
i.y = b
i.z = c
c.r = g
c.o = i
c.q = i
c.t = b
g.z = m
n.x = g
m.z = g
assert n.x.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: C = None
        self.r: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.t: D = None
        self.y: A = None
        self.z: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.o: B = None
        self.t: A = None
        self.q: B = None
        self.txt = txt

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

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

b = A("b")
i = B("i")
c = C("c")
g = D("g")
n = E("n")
m = D("m")

b.o = i
b.r = i
b.t = i
b.p = c
i.p = m
i.t = m
i.y = b
i.z = c
c.r = g
c.o = i
c.q = i
c.t = b
g.z = m
n.x = g
m.z = g
assert n.x.z.z.z.z.z.txt == "m"