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

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

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

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

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

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

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

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

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

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

l.v = i
l.z = g
l.t = a
l.w = a
a.p = i
a.z = i
a.q = n
g.z = i
g.t = a
n.o = i
n.s = i
n.r = a
i.v = l
i.z = g
i.t = a
i.w = a
assert l.z.t.q.s.txt == "i"