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

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

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

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

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

c.t = h
c.v = i
d.t = b
d.r = h
d.z = k
f.s = n
f.p = d
h.s = k
h.w = k
h.x = i
h.r = a
n.t = b
n.r = k
n.z = k
a.s = d
a.p = d
k.s = h
k.w = h
k.x = c
k.r = f
b.s = d
b.p = m
m.t = f
m.r = h
m.z = k
i.t = k
i.v = c
assert h.s.x.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.v: A = None
        self.txt = txt

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

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

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

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

c.t = h
c.v = i
d.t = b
d.r = h
d.z = k
f.s = n
f.p = d
h.s = k
h.w = k
h.x = i
h.r = a
n.t = b
n.r = k
n.z = k
a.s = d
a.p = d
k.s = h
k.w = h
k.x = c
k.r = f
b.s = d
b.p = m
m.t = f
m.r = h
m.z = k
i.t = k
i.v = c
assert h.s.x.v.v.txt == "c"