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

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: E = None
        self.o: C = None
        self.y: D = None
        self.txt = txt

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

b = A("b")
n = B("n")
g = C("g")
i = D("i")
j = E("j")
d = D("d")

b.r = j
b.z = d
n.p = b
n.v = b
n.t = j
n.o = g
g.v = j
g.t = n
g.r = b
i.s = g
i.o = g
i.x = j
i.y = d
j.o = n
j.t = b
j.y = b
d.s = g
d.o = g
d.x = j
d.y = i
assert g.r.r.y.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.s: C = None
        self.x: E = None
        self.o: C = None
        self.y: D = None
        self.txt = txt

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

b = A("b")
n = B("n")
g = C("g")
i = D("i")
j = E("j")
d = D("d")

b.r = j
b.z = d
n.p = b
n.v = b
n.t = j
n.o = g
g.v = j
g.t = n
g.r = b
i.s = g
i.o = g
i.x = j
i.y = d
j.o = n
j.t = b
j.y = b
d.s = g
d.o = g
d.x = j
d.y = i
assert g.r.r.y.r.y.txt == "b"