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

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

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

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

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

g.x = b
g.z = b
g.t = b
b.y = g
b.q = j
j.r = b
j.w = b
j.q = b
l.z = b
assert b.q.w.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: B = None
        self.t: B = None
        self.txt = txt

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

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

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

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

g.x = b
g.z = b
g.t = b
b.y = g
b.q = j
j.r = b
j.w = b
j.q = b
l.z = b
assert b.q.w.q.r.txt == "b"