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

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.s: E = None
        self.t: A = None
        self.txt = txt

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

l = A("l")
d = B("d")
f = C("f")
g = D("g")
b = E("b")

l.x = d
l.s = d
l.p = f
d.y = l
d.s = g
d.w = b
f.r = d
f.t = d
g.o = b
g.s = b
g.t = l
b.p = l
assert b.p.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: B = None
        self.p: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.s: E = None
        self.t: A = None
        self.txt = txt

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

l = A("l")
d = B("d")
f = C("f")
g = D("g")
b = E("b")

l.x = d
l.s = d
l.p = f
d.y = l
d.s = g
d.w = b
f.r = d
f.t = d
g.o = b
g.s = b
g.t = l
b.p = l
assert b.p.p.r.txt == "d"