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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: C = None
        self.z: C = None
        self.txt = txt

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

b = A("b")
m = B("m")
a = C("a")
i = D("i")
f = E("f")
l = D("l")
c = A("c")

b.p = c
b.u = c
b.q = m
b.v = l
m.t = a
a.z = c
a.x = m
a.r = f
i.o = m
i.p = a
i.z = a
f.u = a
f.s = m
f.o = b
l.o = m
l.p = a
l.z = a
c.p = b
c.u = b
c.q = m
c.v = l
assert i.o.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: B = None
        self.v: D = None
        self.u: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: C = None
        self.z: C = None
        self.txt = txt

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

b = A("b")
m = B("m")
a = C("a")
i = D("i")
f = E("f")
l = D("l")
c = A("c")

b.p = c
b.u = c
b.q = m
b.v = l
m.t = a
a.z = c
a.x = m
a.r = f
i.o = m
i.p = a
i.z = a
f.u = a
f.s = m
f.o = b
l.o = m
l.p = a
l.z = a
c.p = b
c.u = b
c.q = m
c.v = l
assert i.o.t.r.txt == "f"