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

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

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

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

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

f.v = h
f.x = a
f.q = g
a.s = g
a.t = d
a.r = h
a.q = c
n.z = d
g.x = f
g.w = d
g.v = n
c.z = d
h.s = g
h.t = d
h.r = i
h.q = e
i.s = g
i.t = d
i.r = a
i.q = c
e.z = f
d.v = a
d.x = i
d.q = g
j.z = f
assert a.s.v.z.x.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: B = None
        self.q: D = None
        self.txt = txt

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

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

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

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

f.v = h
f.x = a
f.q = g
a.s = g
a.t = d
a.r = h
a.q = c
n.z = d
g.x = f
g.w = d
g.v = n
c.z = d
h.s = g
h.t = d
h.r = i
h.q = e
i.s = g
i.t = d
i.r = a
i.q = c
e.z = f
d.v = a
d.x = i
d.q = g
j.z = f
assert a.s.v.z.x.q.z.txt == "d"