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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: A = None
        self.v: D = None
        self.t: B = None
        self.txt = txt

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

b.w = g
c.r = h
g.q = c
i.z = g
i.u = g
i.q = c
h.p = c
h.t = c
h.o = b
h.v = i
assert c.r.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: A = None
        self.v: D = None
        self.t: B = None
        self.txt = txt

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

b.w = g
c.r = h
g.q = c
i.z = g
i.u = g
i.q = c
h.p = c
h.t = c
h.o = b
h.v = i
assert c.r.p.r.p.txt == "c"