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

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

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

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

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

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

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

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

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

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

c.r = f
g.p = f
g.s = h
g.z = h
g.t = j
n.p = l
n.x = j
m.y = g
m.u = k
m.r = k
m.w = h
l.p = m
l.s = j
l.z = j
l.t = h
h.p = l
h.x = n
k.r = m
j.p = g
j.x = n
f.y = l
f.u = k
f.w = h
f.r = c
assert c.r.w.x.x.x.txt == "n"