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

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

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

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

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

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

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

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

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

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

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