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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: C = None
        self.v: F = None
        self.q: D = None
        self.p: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: D = None
        self.u: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.w: A = None
        self.y: A = None
        self.txt = txt

n = A("n")
d = B("d")
i = C("i")
b = D("b")
a = E("a")
l = F("l")
g = B("g")

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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.r: C = None
        self.v: F = None
        self.q: D = None
        self.p: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: D = None
        self.u: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.w: A = None
        self.y: A = None
        self.txt = txt

n = A("n")
d = B("d")
i = C("i")
b = D("b")
a = E("a")
l = F("l")
g = B("g")

n.u = i
d.s = n
d.p = n
d.r = i
d.v = l
d.q = b
i.s = b
i.z = b
i.u = a
b.w = g
a.x = i
l.w = n
l.y = n
g.s = n
g.p = n
g.r = i
g.v = l
g.q = b
assert i.u.x.u.txt == "a"