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

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

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

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

c = A("c")
d = B("d")
l = C("l")
g = D("g")

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

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

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

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

c = A("c")
d = B("d")
l = C("l")
g = D("g")

c.q = d
c.w = d
c.r = d
c.s = g
d.z = l
d.u = g
d.s = c
l.p = g
l.u = c
g.r = c
g.t = c
g.q = l
assert g.q.p.t.r.txt == "d"