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

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

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

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

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

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

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

l = A("l")
a = B("a")
j = C("j")
f = D("f")
b = E("b")
d = F("d")
g = G("g")

l.q = g
a.x = l
a.w = l
a.s = g
j.p = f
j.o = f
j.r = l
f.v = d
f.o = g
f.r = g
f.x = j
f.y = a
b.y = j
d.w = j
g.w = d
g.p = j
assert j.r.q.w.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: G = None
        self.txt = txt

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

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

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

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

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

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

l = A("l")
a = B("a")
j = C("j")
f = D("f")
b = E("b")
d = F("d")
g = G("g")

l.q = g
a.x = l
a.w = l
a.s = g
j.p = f
j.o = f
j.r = l
f.v = d
f.o = g
f.r = g
f.x = j
f.y = a
b.y = j
d.w = j
g.w = d
g.p = j
assert j.r.q.w.w.r.txt == "l"