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

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.x: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

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

e = A("e")
l = B("l")
f = C("f")
a = D("a")
n = E("n")
b = F("b")
d = E("d")

e.r = l
l.o = d
l.x = a
f.x = a
f.z = e
a.y = d
n.s = b
b.o = e
b.s = f
d.s = b
assert n.s.s.z.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: E = None
        self.x: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

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

e = A("e")
l = B("l")
f = C("f")
a = D("a")
n = E("n")
b = F("b")
d = E("d")

e.r = l
l.o = d
l.x = a
f.x = a
f.z = e
a.y = d
n.s = b
b.o = e
b.s = f
d.s = b
assert n.s.s.z.r.txt == "l"