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

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

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

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

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

m = A("m")
f = B("f")
h = C("h")
i = D("i")
g = E("g")
d = A("d")
k = E("k")
c = C("c")
b = C("b")

m.r = c
m.o = h
f.o = h
f.q = m
f.y = b
h.r = f
i.q = g
i.w = g
i.z = c
i.r = k
g.y = f
g.q = f
g.u = k
d.r = h
d.o = c
k.y = f
k.q = f
k.u = g
c.r = f
b.r = f
assert c.r.o.r.q.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.o: C = None
        self.txt = txt

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

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

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

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

m = A("m")
f = B("f")
h = C("h")
i = D("i")
g = E("g")
d = A("d")
k = E("k")
c = C("c")
b = C("b")

m.r = c
m.o = h
f.o = h
f.q = m
f.y = b
h.r = f
i.q = g
i.w = g
i.z = c
i.r = k
g.y = f
g.q = f
g.u = k
d.r = h
d.o = c
k.y = f
k.q = f
k.u = g
c.r = f
b.r = f
assert c.r.o.r.q.r.r.txt == "f"