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

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

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

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

b = A("b")
j = B("j")
k = C("k")
e = D("e")
a = B("a")
n = A("n")

b.y = e
b.x = a
b.r = n
j.u = k
j.p = a
k.q = e
e.y = k
a.u = k
a.p = j
n.y = e
n.x = j
n.r = b
assert n.x.u.q.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.x: B = None
        self.r: A = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
k = C("k")
e = D("e")
a = B("a")
n = A("n")

b.y = e
b.x = a
b.r = n
j.u = k
j.p = a
k.q = e
e.y = k
a.u = k
a.p = j
n.y = e
n.x = j
n.r = b
assert n.x.u.q.y.q.txt == "e"