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

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

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

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

d = A("d")
c = B("c")
h = C("h")
j = D("j")
f = B("f")

d.q = c
d.u = f
d.w = f
c.o = h
c.x = d
c.q = d
h.u = d
h.w = d
h.t = d
h.r = j
j.z = f
j.q = h
j.u = h
j.r = d
f.o = h
f.x = d
f.q = d
assert h.w.q.o.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

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

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

d = A("d")
c = B("c")
h = C("h")
j = D("j")
f = B("f")

d.q = c
d.u = f
d.w = f
c.o = h
c.x = d
c.q = d
h.u = d
h.w = d
h.t = d
h.r = j
j.z = f
j.q = h
j.u = h
j.r = d
f.o = h
f.x = d
f.q = d
assert h.w.q.o.t.w.txt == "f"