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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: C = None
        self.w: D = None
        self.y: D = None
        self.o: A = None
        self.txt = txt

n = A("n")
f = B("f")
i = C("i")
a = D("a")
d = E("d")
h = F("h")
l = E("l")

n.s = i
f.x = a
i.q = f
i.x = n
i.v = n
a.s = f
d.y = a
d.r = a
d.v = i
d.p = l
h.u = f
h.x = i
h.w = a
h.y = a
h.o = n
l.y = a
l.r = a
l.v = i
l.p = d
assert f.x.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: C = None
        self.w: D = None
        self.y: D = None
        self.o: A = None
        self.txt = txt

n = A("n")
f = B("f")
i = C("i")
a = D("a")
d = E("d")
h = F("h")
l = E("l")

n.s = i
f.x = a
i.q = f
i.x = n
i.v = n
a.s = f
d.y = a
d.r = a
d.v = i
d.p = l
h.u = f
h.x = i
h.w = a
h.y = a
h.o = n
l.y = a
l.r = a
l.v = i
l.p = d
assert f.x.s.x.txt == "a"