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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: B = None
        self.p: D = None
        self.u: A = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: B = None
        self.p: D = None
        self.u: A = None
        self.txt = txt

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

h.q = l
h.z = m
h.t = m
h.x = g
m.p = h
m.r = h
m.q = i
c.y = m
i.r = j
i.y = m
i.p = l
i.u = h
g.y = m
k.y = m
j.r = i
j.y = m
j.p = l
j.u = h
l.r = i
l.p = i
l.y = m
l.u = h
assert j.p.y.q.r.y.q.u.q.txt == "l"