class A:
    def __init__(self, txt: str):
        self.r: G = None
        self.u: C = None
        self.x: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: G = None
        self.q: B = None
        self.s: C = None
        self.z: B = None
        self.u: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: C = None
        self.q: D = None
        self.u: A = None
        self.txt = txt

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

i = A("i")
m = B("m")
j = C("j")
h = D("h")
c = E("c")
b = F("b")
d = G("d")

i.r = d
i.u = j
i.x = j
m.x = b
m.s = b
j.y = c
h.t = d
h.q = m
h.z = m
h.u = m
h.s = j
c.q = i
b.r = m
b.z = j
b.q = h
b.u = i
d.w = h
assert d.w.s.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: G = None
        self.u: C = None
        self.x: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: G = None
        self.q: B = None
        self.s: C = None
        self.z: B = None
        self.u: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: C = None
        self.q: D = None
        self.u: A = None
        self.txt = txt

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

i = A("i")
m = B("m")
j = C("j")
h = D("h")
c = E("c")
b = F("b")
d = G("d")

i.r = d
i.u = j
i.x = j
m.x = b
m.s = b
j.y = c
h.t = d
h.q = m
h.z = m
h.u = m
h.s = j
c.q = i
b.r = m
b.z = j
b.q = h
b.u = i
d.w = h
assert d.w.s.y.q.txt == "i"