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

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

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

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

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

a.p = e
a.q = e
a.s = n
l.x = a
l.u = e
e.p = n
e.v = n
e.u = l
e.x = a
i.u = j
j.p = e
j.q = e
j.s = i
n.u = j
assert e.u.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

a.p = e
a.q = e
a.s = n
l.x = a
l.u = e
e.p = n
e.v = n
e.u = l
e.x = a
i.u = j
j.p = e
j.q = e
j.s = i
n.u = j
assert e.u.u.p.txt == "n"