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

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

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

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

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

b.u = m
b.v = m
b.y = j
b.t = i
i.v = d
i.x = d
i.u = d
i.z = m
e.w = j
j.t = e
d.w = j
m.v = d
m.x = d
m.z = i
m.u = e
assert e.w.t.w.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: B = None
        self.y: D = None
        self.t: B = None
        self.txt = txt

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

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

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

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

b.u = m
b.v = m
b.y = j
b.t = i
i.v = d
i.x = d
i.u = d
i.z = m
e.w = j
j.t = e
d.w = j
m.v = d
m.x = d
m.z = i
m.u = e
assert e.w.t.w.t.w.t.txt == "e"