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

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

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

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

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

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

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

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

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

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

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