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

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: E = None
        self.t: C = None
        self.y: G = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: C = None
        self.w: C = None
        self.t: E = None
        self.s: A = None
        self.v: E = None
        self.txt = txt

g = A("g")
m = B("m")
d = C("d")
b = D("b")
k = E("k")
f = F("f")
n = G("n")
i = C("i")

g.q = m
g.v = b
g.r = d
g.x = n
m.s = n
d.r = b
b.q = d
b.u = k
b.t = i
b.y = n
k.w = d
f.y = m
n.p = b
n.r = i
n.w = d
n.t = k
n.v = k
n.s = g
i.r = b
assert d.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: D = None
        self.r: C = None
        self.x: G = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: E = None
        self.t: C = None
        self.y: G = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: C = None
        self.w: C = None
        self.t: E = None
        self.s: A = None
        self.v: E = None
        self.txt = txt

g = A("g")
m = B("m")
d = C("d")
b = D("b")
k = E("k")
f = F("f")
n = G("n")
i = C("i")

g.q = m
g.v = b
g.r = d
g.x = n
m.s = n
d.r = b
b.q = d
b.u = k
b.t = i
b.y = n
k.w = d
f.y = m
n.p = b
n.r = i
n.w = d
n.t = k
n.v = k
n.s = g
i.r = b
assert d.r.t.r.txt == "b"