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

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

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

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

n = A("n")
m = B("m")
l = C("l")
a = D("a")
e = C("e")

n.u = l
m.p = n
l.q = n
a.q = e
a.o = l
e.q = n
assert m.p.u.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

n = A("n")
m = B("m")
l = C("l")
a = D("a")
e = C("e")

n.u = l
m.p = n
l.q = n
a.q = e
a.o = l
e.q = n
assert m.p.u.q.u.txt == "l"