class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: D = None
        self.v: E = None
        self.r: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

k = A("k")
h = B("h")
b = C("b")
i = D("i")
j = E("j")

k.w = b
k.p = i
k.r = i
k.v = j
h.t = b
b.p = k
b.q = i
b.t = h
i.y = k
i.q = b
i.w = b
j.p = i
assert i.q.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: D = None
        self.v: E = None
        self.r: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

k = A("k")
h = B("h")
b = C("b")
i = D("i")
j = E("j")

k.w = b
k.p = i
k.r = i
k.v = j
h.t = b
b.p = k
b.q = i
b.t = h
i.y = k
i.q = b
i.w = b
j.p = i
assert i.q.p.w.txt == "b"