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

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

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

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

e = A("e")
j = B("j")
n = C("n")
c = D("c")
d = A("d")

e.q = j
e.t = n
j.u = n
j.q = c
n.u = c
c.x = e
d.q = j
d.t = n
assert e.q.q.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: C = None
        self.txt = txt

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

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

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

e = A("e")
j = B("j")
n = C("n")
c = D("c")
d = A("d")

e.q = j
e.t = n
j.u = n
j.q = c
n.u = c
c.x = e
d.q = j
d.t = n
assert e.q.q.x.q.txt == "j"