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

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

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

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

b = A("b")
g = B("g")
i = C("i")
j = D("j")
n = B("n")
l = A("l")
e = A("e")
k = D("k")
m = D("m")
f = C("f")

b.w = f
b.r = e
g.p = n
g.w = l
i.t = k
i.z = k
i.u = k
j.z = l
n.p = g
n.w = e
l.w = f
l.r = b
e.w = f
e.r = b
k.z = b
m.z = b
f.t = k
f.z = k
f.u = j
assert g.p.p.w.r.w.z.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: A = None
        self.txt = txt

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

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

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

b = A("b")
g = B("g")
i = C("i")
j = D("j")
n = B("n")
l = A("l")
e = A("e")
k = D("k")
m = D("m")
f = C("f")

b.w = f
b.r = e
g.p = n
g.w = l
i.t = k
i.z = k
i.u = k
j.z = l
n.p = g
n.w = e
l.w = f
l.r = b
e.w = f
e.r = b
k.z = b
m.z = b
f.t = k
f.z = k
f.u = j
assert g.p.p.w.r.w.z.z.w.txt == "f"