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

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: F = None
        self.z: B = None
        self.y: E = None
        self.r: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: E = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: E = None
        self.o: C = None
        self.s: D = None
        self.txt = txt

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

n.q = j
n.v = a
g.u = l
b.w = l
a.u = j
a.z = g
a.r = g
a.y = l
i.v = n
j.u = g
j.v = i
m.q = b
m.o = b
m.x = i
m.s = a
l.v = n
assert n.v.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.v: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.u: F = None
        self.z: B = None
        self.y: E = None
        self.r: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.u: B = None
        self.v: E = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: E = None
        self.o: C = None
        self.s: D = None
        self.txt = txt

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

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