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

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

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

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

h = A("h")
j = B("j")
k = C("k")
i = D("i")
d = B("d")
e = A("e")
c = C("c")
l = D("l")

h.x = k
h.y = l
h.s = e
j.y = h
j.q = e
k.t = c
k.z = l
k.x = j
k.y = e
i.q = h
d.y = e
d.q = h
e.x = c
e.y = i
e.s = h
c.t = k
c.z = i
c.x = d
c.y = e
l.q = e
assert e.s.x.z.q.y.q.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: D = None
        self.s: A = None
        self.txt = txt

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

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

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

h = A("h")
j = B("j")
k = C("k")
i = D("i")
d = B("d")
e = A("e")
c = C("c")
l = D("l")

h.x = k
h.y = l
h.s = e
j.y = h
j.q = e
k.t = c
k.z = l
k.x = j
k.y = e
i.q = h
d.y = e
d.q = h
e.x = c
e.y = i
e.s = h
c.t = k
c.z = i
c.x = d
c.y = e
l.q = e
assert e.s.x.z.q.y.q.x.y.txt == "e"