class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.x: C = None
        self.txt = txt

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

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

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

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

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

d.o = g
d.x = l
n.x = g
n.p = m
b.q = l
m.x = c
m.t = d
m.u = d
g.x = d
g.p = d
c.x = g
c.p = m
l.q = b
assert d.o.p.x.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.x: C = None
        self.txt = txt

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

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

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

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

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

d.o = g
d.x = l
n.x = g
n.p = m
b.q = l
m.x = c
m.t = d
m.u = d
g.x = d
g.p = d
c.x = g
c.p = m
l.q = b
assert d.o.p.x.q.q.q.q.txt == "l"