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

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

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

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

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

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

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

n.q = g
c.t = f
c.x = b
c.r = b
c.v = a
c.q = i
c.o = n
g.v = j
g.q = a
a.y = b
f.o = g
i.s = c
i.y = b
i.u = a
i.w = a
b.t = f
b.x = c
b.r = c
b.v = a
b.q = d
b.o = n
j.v = g
j.q = a
d.s = b
d.y = b
d.u = a
d.w = a
assert a.y.x.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

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

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

n.q = g
c.t = f
c.x = b
c.r = b
c.v = a
c.q = i
c.o = n
g.v = j
g.q = a
a.y = b
f.o = g
i.s = c
i.y = b
i.u = a
i.w = a
b.t = f
b.x = c
b.r = c
b.v = a
b.q = d
b.o = n
j.v = g
j.q = a
d.s = b
d.y = b
d.u = a
d.w = a
assert a.y.x.t.o.txt == "g"