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

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

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

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

e = A("e")
l = B("l")
g = C("g")
b = D("b")

e.y = l
e.q = l
e.s = l
e.x = g
l.q = b
g.p = l
g.x = b
g.z = e
b.v = e
assert e.x.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.s: B = None
        self.x: C = None
        self.txt = txt

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

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

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

e = A("e")
l = B("l")
g = C("g")
b = D("b")

e.y = l
e.q = l
e.s = l
e.x = g
l.q = b
g.p = l
g.x = b
g.z = e
b.v = e
assert e.x.z.q.txt == "l"