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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: G = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: G = None
        self.x: D = None
        self.txt = txt

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

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

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

a.u = g
a.x = m
j.x = b
j.q = m
l.o = g
g.v = m
b.u = e
b.x = g
m.q = a
m.r = a
m.o = b
m.v = j
m.x = l
e.o = g
e.s = g
e.x = g
e.q = a
e.w = l
assert j.q.r.x.x.o.v.r.txt == "a"