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

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

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

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

f = A("f")
j = B("j")
k = C("k")
g = D("g")
e = D("e")
h = C("h")
i = A("i")
l = A("l")

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

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

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

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

f = A("f")
j = B("j")
k = C("k")
g = D("g")
e = D("e")
h = C("h")
i = A("i")
l = A("l")

f.z = k
j.r = h
k.w = h
k.t = h
k.s = i
g.z = i
g.w = j
g.r = e
e.z = f
e.w = j
e.r = g
h.w = k
h.t = k
h.s = l
i.z = k
l.z = h
assert g.w.r.t.t.txt == "h"