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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: A = None
        self.q: B = None
        self.p: B = None
        self.w: B = None
        self.txt = txt

b = A("b")
j = B("j")
e = C("e")
g = D("g")
f = E("f")
h = D("h")

b.r = e
b.t = j
j.r = b
e.s = j
e.o = j
e.w = f
e.p = f
g.s = j
g.v = e
g.q = h
f.y = g
f.z = b
f.q = j
f.p = j
f.w = j
h.s = j
h.v = e
h.q = g
assert b.t.r.r.p.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.t: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: A = None
        self.q: B = None
        self.p: B = None
        self.w: B = None
        self.txt = txt

b = A("b")
j = B("j")
e = C("e")
g = D("g")
f = E("f")
h = D("h")

b.r = e
b.t = j
j.r = b
e.s = j
e.o = j
e.w = f
e.p = f
g.s = j
g.v = e
g.q = h
f.y = g
f.z = b
f.q = j
f.p = j
f.w = j
h.s = j
h.v = e
h.q = g
assert b.t.r.r.p.z.t.txt == "j"