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

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

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

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

k = A("k")
g = B("g")
e = C("e")
h = D("h")
i = A("i")
f = C("f")

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

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

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

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

k = A("k")
g = B("g")
e = C("e")
h = D("h")
i = A("i")
f = C("f")

k.w = f
g.u = e
e.x = f
e.y = f
h.w = k
h.u = k
h.q = g
h.r = i
i.w = e
f.x = e
f.y = e
assert h.u.w.y.y.x.y.txt == "f"