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

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

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

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

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

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

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

l = A("l")
h = B("h")
e = C("e")
m = D("m")
i = E("i")
b = F("b")
f = G("f")

l.q = e
h.q = i
e.q = l
e.s = m
m.x = e
m.q = b
i.p = b
i.r = l
b.w = f
b.p = m
f.s = m
assert e.s.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

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

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

l = A("l")
h = B("h")
e = C("e")
m = D("m")
i = E("i")
b = F("b")
f = G("f")

l.q = e
h.q = i
e.q = l
e.s = m
m.x = e
m.q = b
i.p = b
i.r = l
b.w = f
b.p = m
f.s = m
assert e.s.q.p.txt == "m"