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

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

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

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

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

k.q = m
h.w = n
h.s = j
m.z = h
m.q = c
m.s = d
m.t = n
j.x = d
g.z = h
g.q = m
g.s = d
g.t = n
n.q = g
d.x = j
l.z = h
l.q = c
l.s = j
l.t = k
c.z = h
c.q = m
c.s = j
c.t = n
assert g.q.t.q.s.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

k.q = m
h.w = n
h.s = j
m.z = h
m.q = c
m.s = d
m.t = n
j.x = d
g.z = h
g.q = m
g.s = d
g.t = n
n.q = g
d.x = j
l.z = h
l.q = c
l.s = j
l.t = k
c.z = h
c.q = m
c.s = j
c.t = n
assert g.q.t.q.s.x.x.txt == "d"