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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: C = None
        self.r: C = None
        self.v: C = None
        self.p: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: B = None
        self.v: E = None
        self.s: A = None
        self.u: A = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
c = C("c")
k = D("k")
j = E("j")

d.r = j
b.s = d
b.q = c
b.r = c
b.v = c
b.p = c
c.p = d
c.s = d
c.u = d
c.x = b
c.v = j
k.r = c
k.p = d
k.v = b
j.q = b
j.t = c
assert k.v.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: C = None
        self.r: C = None
        self.v: C = None
        self.p: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: B = None
        self.v: E = None
        self.s: A = None
        self.u: A = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
c = C("c")
k = D("k")
j = E("j")

d.r = j
b.s = d
b.q = c
b.r = c
b.v = c
b.p = c
c.p = d
c.s = d
c.u = d
c.x = b
c.v = j
k.r = c
k.p = d
k.v = b
j.q = b
j.t = c
assert k.v.v.x.txt == "b"