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

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

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

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

l = A("l")
f = B("f")
b = C("b")
i = D("i")
c = B("c")
m = A("m")

l.q = m
l.s = i
l.t = i
f.x = i
f.z = i
f.p = b
f.w = c
b.y = m
i.r = b
c.x = i
c.z = i
c.p = b
c.w = f
m.q = l
m.s = i
m.t = i
assert c.z.r.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

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

l = A("l")
f = B("f")
b = C("b")
i = D("i")
c = B("c")
m = A("m")

l.q = m
l.s = i
l.t = i
f.x = i
f.z = i
f.p = b
f.w = c
b.y = m
i.r = b
c.x = i
c.z = i
c.p = b
c.w = f
m.q = l
m.s = i
m.t = i
assert c.z.r.y.q.txt == "l"