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

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: D = None
        self.txt = txt

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

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

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: D = None
        self.txt = txt

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

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

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

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

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

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

f.w = l
f.q = a
l.p = a
l.v = j
e.p = g
j.x = c
j.r = m
b.p = m
b.r = a
b.y = a
b.s = c
m.y = e
m.v = f
g.q = e
a.p = l
a.v = j
c.p = m
c.r = l
c.y = a
c.s = b
assert e.p.q.p.q.p.q.p.q.p.txt == "g"