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

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.s: B = None
        self.p: A = None
        self.o: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: B = None
        self.s: B = None
        self.txt = txt

f = A("f")
j = B("j")
l = C("l")
b = D("b")
n = E("n")
h = A("h")

f.z = h
f.y = h
j.w = h
j.u = n
j.r = l
l.z = n
l.s = j
l.o = j
l.p = h
b.x = h
b.p = j
n.w = j
n.x = j
n.s = j
h.z = f
h.y = f
assert j.r.o.w.z.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: E = None
        self.s: B = None
        self.p: A = None
        self.o: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: B = None
        self.s: B = None
        self.txt = txt

f = A("f")
j = B("j")
l = C("l")
b = D("b")
n = E("n")
h = A("h")

f.z = h
f.y = h
j.w = h
j.u = n
j.r = l
l.z = n
l.s = j
l.o = j
l.p = h
b.x = h
b.p = j
n.w = j
n.x = j
n.s = j
h.z = f
h.y = f
assert j.r.o.w.z.y.z.txt == "f"