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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

a.x = m
j.u = n
n.q = g
c.p = m
c.w = j
l.p = m
m.q = g
m.p = c
m.u = b
g.s = a
b.x = m
assert c.w.u.q.s.x.q.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

a.x = m
j.u = n
n.q = g
c.p = m
c.w = j
l.p = m
m.q = g
m.p = c
m.u = b
g.s = a
b.x = m
assert c.w.u.q.s.x.q.s.x.txt == "m"