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

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

class C:
    def __init__(self, txt: str):
        self.y: 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.u: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: C = None
        self.v: A = None
        self.t: D = None
        self.txt = txt

a = A("a")
d = B("d")
b = C("b")
g = D("g")
k = E("k")
m = F("m")
n = E("n")
f = B("f")

a.q = b
a.y = g
d.x = b
d.v = a
d.o = n
b.y = n
g.w = d
k.u = a
m.o = g
m.t = g
m.q = b
m.v = a
n.u = a
f.x = b
f.v = a
f.o = n
assert n.u.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: 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.u: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: C = None
        self.v: A = None
        self.t: D = None
        self.txt = txt

a = A("a")
d = B("d")
b = C("b")
g = D("g")
k = E("k")
m = F("m")
n = E("n")
f = B("f")

a.q = b
a.y = g
d.x = b
d.v = a
d.o = n
b.y = n
g.w = d
k.u = a
m.o = g
m.t = g
m.q = b
m.v = a
n.u = a
f.x = b
f.v = a
f.o = n
assert n.u.q.y.txt == "n"