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

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

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

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

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

g.v = b
g.y = b
g.x = a
e.x = a
e.v = i
e.s = g
a.y = b
a.w = b
a.v = g
b.q = e
b.t = e
b.r = a
i.y = b
i.w = b
i.v = g
assert a.w.t.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.x: C = None
        self.y: D = None
        self.txt = txt

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

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

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

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

g.v = b
g.y = b
g.x = a
e.x = a
e.v = i
e.s = g
a.y = b
a.w = b
a.v = g
b.q = e
b.t = e
b.r = a
i.y = b
i.w = b
i.v = g
assert a.w.t.s.v.txt == "b"