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

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

class C:
    def __init__(self, txt: str):
        self.y: F = None
        self.s: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.w: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: B = None
        self.p: F = None
        self.z: C = None
        self.t: C = None
        self.q: B = None
        self.txt = txt

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

j.q = d
j.u = m
n.s = j
m.y = k
m.s = d
a.t = j
d.u = k
k.w = b
b.v = j
b.r = n
b.q = n
b.p = k
b.z = m
b.t = m
assert n.s.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.u: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: F = None
        self.s: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.w: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: B = None
        self.p: F = None
        self.z: C = None
        self.t: C = None
        self.q: B = None
        self.txt = txt

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

j.q = d
j.u = m
n.s = j
m.y = k
m.s = d
a.t = j
d.u = k
k.w = b
b.v = j
b.r = n
b.q = n
b.p = k
b.z = m
b.t = m
assert n.s.u.s.txt == "d"