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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: D = None
        self.t: C = None
        self.r: B = None
        self.txt = txt

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

a = A("a")
h = B("h")
j = C("j")
m = D("m")
i = D("i")
e = C("e")
b = B("b")
n = B("n")
g = C("g")
k = D("k")

a.s = e
h.x = b
j.w = b
j.o = m
j.t = g
j.r = n
m.q = i
m.y = b
m.u = e
m.o = a
i.q = m
i.y = h
i.u = e
i.o = a
e.w = n
e.r = n
e.o = m
e.t = g
b.x = n
n.x = h
g.w = n
g.r = n
g.o = m
g.t = j
k.q = m
k.y = h
k.u = g
k.o = a
assert i.q.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: D = None
        self.t: C = None
        self.r: B = None
        self.txt = txt

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

a = A("a")
h = B("h")
j = C("j")
m = D("m")
i = D("i")
e = C("e")
b = B("b")
n = B("n")
g = C("g")
k = D("k")

a.s = e
h.x = b
j.w = b
j.o = m
j.t = g
j.r = n
m.q = i
m.y = b
m.u = e
m.o = a
i.q = m
i.y = h
i.u = e
i.o = a
e.w = n
e.r = n
e.o = m
e.t = g
b.x = n
n.x = h
g.w = n
g.r = n
g.o = m
g.t = j
k.q = m
k.y = h
k.u = g
k.o = a
assert i.q.u.o.txt == "m"