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

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

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

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

i = A("i")
c = B("c")
a = C("a")
h = D("h")
e = D("e")
g = A("g")
d = B("d")
j = D("j")
f = A("f")
m = B("m")

i.y = c
i.q = j
i.z = m
c.x = m
c.r = j
c.z = a
a.s = g
h.t = j
h.o = f
h.u = a
h.p = d
e.t = h
e.o = i
e.u = a
e.p = m
g.y = m
g.q = h
g.z = d
d.x = m
d.r = j
d.z = a
j.t = e
j.o = g
j.u = a
j.p = d
f.y = d
f.z = d
f.q = h
m.x = d
m.r = e
m.z = a
assert m.r.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: D = None
        self.z: B = None
        self.txt = txt

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

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

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

i = A("i")
c = B("c")
a = C("a")
h = D("h")
e = D("e")
g = A("g")
d = B("d")
j = D("j")
f = A("f")
m = B("m")

i.y = c
i.q = j
i.z = m
c.x = m
c.r = j
c.z = a
a.s = g
h.t = j
h.o = f
h.u = a
h.p = d
e.t = h
e.o = i
e.u = a
e.p = m
g.y = m
g.q = h
g.z = d
d.x = m
d.r = j
d.z = a
j.t = e
j.o = g
j.u = a
j.p = d
f.y = d
f.z = d
f.q = h
m.x = d
m.r = e
m.z = a
assert m.r.u.s.txt == "g"