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

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

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

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

d = A("d")
l = B("l")
h = C("h")
k = D("k")
a = B("a")

d.q = a
d.z = a
d.r = k
l.s = d
l.o = d
l.t = a
h.y = d
h.s = d
h.x = a
k.w = d
a.s = d
a.o = d
a.t = l
assert a.o.r.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: D = None
        self.z: B = None
        self.txt = txt

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

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

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

d = A("d")
l = B("l")
h = C("h")
k = D("k")
a = B("a")

d.q = a
d.z = a
d.r = k
l.s = d
l.o = d
l.t = a
h.y = d
h.s = d
h.x = a
k.w = d
a.s = d
a.o = d
a.t = l
assert a.o.r.w.z.txt == "a"