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

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

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

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

c = A("c")
d = B("d")
k = C("k")
e = D("e")
h = B("h")
i = A("i")

c.q = k
d.w = k
d.p = e
d.u = e
k.p = e
k.u = e
k.r = e
k.y = i
e.y = k
e.x = i
e.w = d
h.w = k
h.p = e
h.u = e
i.q = k
assert d.w.u.w.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

c = A("c")
d = B("d")
k = C("k")
e = D("e")
h = B("h")
i = A("i")

c.q = k
d.w = k
d.p = e
d.u = e
k.p = e
k.u = e
k.r = e
k.y = i
e.y = k
e.x = i
e.w = d
h.w = k
h.p = e
h.u = e
i.q = k
assert d.w.u.w.w.y.txt == "i"