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

class B:
    def __init__(self, txt: str):
        self.s: E = None
        self.v: 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: C = None
        self.q: A = None
        self.p: C = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.s: E = None
        self.v: 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: C = None
        self.q: A = None
        self.p: C = None
        self.txt = txt

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

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

b.r = f
l.s = a
l.v = b
n.o = i
f.r = n
f.p = n
f.q = b
i.t = n
a.t = n
assert a.t.o.t.o.txt == "i"