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

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: C = None
        self.v: C = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: C = None
        self.v: C = None
        self.txt = txt

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

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