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

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

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

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

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

d.p = g
d.v = a
h.z = e
h.r = c
h.t = i
f.s = b
f.t = c
f.q = g
b.y = e
m.s = e
m.t = f
m.q = g
a.s = b
a.t = f
a.q = g
c.s = e
c.t = m
c.q = g
g.z = b
g.r = a
g.t = i
e.y = b
i.p = h
i.v = c
assert d.v.t.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: C = None
        self.txt = txt

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

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

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

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

d.p = g
d.v = a
h.z = e
h.r = c
h.t = i
f.s = b
f.t = c
f.q = g
b.y = e
m.s = e
m.t = f
m.q = g
a.s = b
a.t = f
a.q = g
c.s = e
c.t = m
c.q = g
g.z = b
g.r = a
g.t = i
e.y = b
i.p = h
i.v = c
assert d.v.t.t.s.txt == "e"