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

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

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

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

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

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

j.r = b
j.o = b
j.q = i
g.p = j
b.o = n
i.r = j
n.s = b
n.v = g
assert b.o.s.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.q: D = None
        self.o: C = None
        self.txt = txt

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

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

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

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

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

j.r = b
j.o = b
j.q = i
g.p = j
b.o = n
i.r = j
n.s = b
n.v = g
assert b.o.s.o.v.txt == "g"