class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: D = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
n = C("n")
i = D("i")

g.w = a
g.o = i
a.s = i
n.t = i
i.v = n
i.z = n
assert i.v.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: D = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
n = C("n")
i = D("i")

g.w = a
g.o = i
a.s = i
n.t = i
i.v = n
i.z = n
assert i.v.t.z.txt == "n"