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

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

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

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

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

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

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

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

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

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

f.t = i
f.z = i
k.y = d
k.w = d
k.x = i
i.w = f
i.q = d
j.v = i
j.x = g
j.y = g
j.t = f
m.w = f
m.q = d
h.w = f
h.q = k
b.v = m
b.x = g
b.y = g
b.t = f
d.y = k
d.w = k
d.x = h
g.v = i
g.x = j
g.y = b
g.t = f
assert g.v.w.t.w.txt == "f"