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

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

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: E = None
        self.y: E = None
        self.w: A = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
e = C("e")
a = D("a")
b = E("b")
h = A("h")

c.r = b
i.x = h
e.z = i
e.v = b
e.y = b
e.w = c
a.o = e
a.r = e
b.v = i
b.u = i
b.q = i
b.r = h
h.r = b
assert i.x.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: E = None
        self.y: E = None
        self.w: A = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
e = C("e")
a = D("a")
b = E("b")
h = A("h")

c.r = b
i.x = h
e.z = i
e.v = b
e.y = b
e.w = c
a.o = e
a.r = e
b.v = i
b.u = i
b.q = i
b.r = h
h.r = b
assert i.x.r.r.r.r.r.txt == "b"