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

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

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

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

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

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

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

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

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

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

k.y = g
k.r = d
k.q = d
k.z = n
c.w = h
c.r = m
c.p = d
m.x = c
m.z = l
l.x = k
l.y = d
l.p = d
d.x = n
d.y = l
d.p = l
j.w = c
j.r = m
j.p = d
g.x = h
g.z = l
n.y = m
n.r = l
n.q = l
n.z = k
h.w = c
h.r = g
h.p = d
assert c.w.r.z.p.x.z.y.z.txt == "l"