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

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

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

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

g = A("g")
h = B("h")
i = C("i")
a = D("a")
b = C("b")
f = B("f")

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

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

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

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

g = A("g")
h = B("h")
i = C("i")
a = D("a")
b = C("b")
f = B("f")

g.v = h
h.q = a
h.z = a
h.w = f
h.r = b
i.s = h
a.p = f
a.v = f
a.t = f
a.s = g
b.s = f
f.q = a
f.z = a
f.w = h
f.r = b
assert h.w.r.s.q.v.txt == "f"