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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: E = None
        self.o: D = None
        self.z: A = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
j = C("j")
i = D("i")
e = E("e")
f = B("f")

g.r = f
m.o = g
m.v = g
j.w = m
j.v = e
j.o = i
j.z = g
i.u = e
i.y = g
e.q = g
f.o = g
f.v = g
assert e.q.r.v.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: E = None
        self.o: D = None
        self.z: A = None
        self.txt = txt

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

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

g = A("g")
m = B("m")
j = C("j")
i = D("i")
e = E("e")
f = B("f")

g.r = f
m.o = g
m.v = g
j.w = m
j.v = e
j.o = i
j.z = g
i.u = e
i.y = g
e.q = g
f.o = g
f.v = g
assert e.q.r.v.r.o.r.txt == "f"