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

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

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

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

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

m.y = i
j.x = n
j.p = n
j.s = l
j.t = m
a.q = k
n.o = i
n.q = k
n.z = j
l.y = a
i.q = j
k.x = n
k.p = n
k.s = m
k.t = l
assert l.y.q.t.y.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

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

m.y = i
j.x = n
j.p = n
j.s = l
j.t = m
a.q = k
n.o = i
n.q = k
n.z = j
l.y = a
i.q = j
k.x = n
k.p = n
k.s = m
k.t = l
assert l.y.q.t.y.q.s.txt == "m"