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

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: B = None
        self.p: C = None
        self.q: B = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

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

a.p = g
a.y = d
j.o = i
j.u = c
j.q = c
j.p = n
j.r = d
l.y = f
l.o = d
l.v = n
l.s = c
d.v = i
d.x = j
d.r = j
d.p = g
i.z = d
i.s = n
g.q = j
g.y = f
f.v = d
f.u = l
f.x = g
f.y = j
c.o = i
c.u = j
c.q = j
c.p = n
c.r = d
n.y = f
n.o = d
n.v = l
n.s = j
assert j.r.r.r.p.q.r.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: B = None
        self.p: C = None
        self.q: B = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

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

a.p = g
a.y = d
j.o = i
j.u = c
j.q = c
j.p = n
j.r = d
l.y = f
l.o = d
l.v = n
l.s = c
d.v = i
d.x = j
d.r = j
d.p = g
i.z = d
i.s = n
g.q = j
g.y = f
f.v = d
f.u = l
f.x = g
f.y = j
c.o = i
c.u = j
c.q = j
c.p = n
c.r = d
n.y = f
n.o = d
n.v = l
n.s = j
assert j.r.r.r.p.q.r.p.q.txt == "j"