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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: B = None
        self.p: C = None
        self.v: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: B = None
        self.v: A = None
        self.x: B = None
        self.txt = txt

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

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

h.y = a
h.q = g
h.p = e
c.q = g
c.u = k
c.p = j
c.v = m
j.t = i
j.y = k
j.v = e
j.x = c
m.x = h
e.y = j
e.q = g
e.p = i
a.t = e
a.v = e
a.y = c
a.x = k
i.y = a
i.q = m
i.p = e
f.t = i
f.v = i
f.y = k
f.x = k
g.x = h
k.q = m
k.u = c
k.p = j
k.v = g
assert h.y.x.q.x.q.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: D = None
        self.p: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: B = None
        self.p: C = None
        self.v: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: B = None
        self.v: A = None
        self.x: B = None
        self.txt = txt

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

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

h.y = a
h.q = g
h.p = e
c.q = g
c.u = k
c.p = j
c.v = m
j.t = i
j.y = k
j.v = e
j.x = c
m.x = h
e.y = j
e.q = g
e.p = i
a.t = e
a.v = e
a.y = c
a.x = k
i.y = a
i.q = m
i.p = e
f.t = i
f.v = i
f.y = k
f.x = k
g.x = h
k.q = m
k.u = c
k.p = j
k.v = g
assert h.y.x.q.x.q.x.y.txt == "a"