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

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

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

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

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

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

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

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

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

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

l.r = i
l.z = n
l.q = g
l.w = g
g.u = i
g.x = n
g.p = n
g.r = l
i.s = g
i.y = g
i.t = l
i.r = n
n.x = i
assert n.x.t.z.x.txt == "i"