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

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

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

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

b = A("b")
d = B("d")
a = C("a")
m = D("m")
i = B("i")

b.y = m
d.p = m
d.u = m
d.w = a
d.v = b
a.x = i
a.t = d
m.x = b
m.p = i
m.y = d
m.s = d
i.p = m
i.u = m
i.w = a
i.v = b
assert i.v.y.s.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

b = A("b")
d = B("d")
a = C("a")
m = D("m")
i = B("i")

b.y = m
d.p = m
d.u = m
d.w = a
d.v = b
a.x = i
a.t = d
m.x = b
m.p = i
m.y = d
m.s = d
i.p = m
i.u = m
i.w = a
i.v = b
assert i.v.y.s.u.y.txt == "d"