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

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

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

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

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

f.u = m
g.w = d
g.p = b
g.u = b
m.z = d
k.y = a
k.t = b
k.w = i
k.p = f
a.y = k
a.w = k
a.t = b
a.p = h
i.y = k
i.w = k
i.t = j
i.p = h
b.w = m
b.p = g
b.u = j
h.u = d
d.z = m
j.w = d
j.p = g
j.u = b
assert g.p.p.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

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

f.u = m
g.w = d
g.p = b
g.u = b
m.z = d
k.y = a
k.t = b
k.w = i
k.p = f
a.y = k
a.w = k
a.t = b
a.p = h
i.y = k
i.w = k
i.t = j
i.p = h
b.w = m
b.p = g
b.u = j
h.u = d
d.z = m
j.w = d
j.p = g
j.u = b
assert g.p.p.w.z.txt == "m"