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

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

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

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

j = A("j")
b = B("b")
e = C("e")
a = D("a")
h = D("h")
l = C("l")

j.r = b
j.u = b
j.z = h
j.v = e
b.u = j
e.z = l
a.x = b
a.w = e
a.p = h
a.z = j
h.x = b
h.w = e
h.p = a
h.z = j
l.z = e
assert h.w.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.z: D = None
        self.v: C = None
        self.txt = txt

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

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

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

j = A("j")
b = B("b")
e = C("e")
a = D("a")
h = D("h")
l = C("l")

j.r = b
j.u = b
j.z = h
j.v = e
b.u = j
e.z = l
a.x = b
a.w = e
a.p = h
a.z = j
h.x = b
h.w = e
h.p = a
h.z = j
l.z = e
assert h.w.z.z.z.z.txt == "e"