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

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.t: B = None
        self.txt = txt

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

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

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

class G:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: E = None
        self.p: D = None
        self.txt = txt

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

e.q = j
e.s = h
c.y = h
c.o = i
n.r = e
n.t = c
b.v = e
f.q = b
f.p = d
f.o = e
h.r = f
j.q = f
j.r = f
j.p = m
d.r = e
d.t = c
m.v = e
i.q = j
i.s = h
assert h.r.q.v.q.p.v.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: G = None
        self.s: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: A = None
        self.t: B = None
        self.txt = txt

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

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

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

class G:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: E = None
        self.p: D = None
        self.txt = txt

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

e.q = j
e.s = h
c.y = h
c.o = i
n.r = e
n.t = c
b.v = e
f.q = b
f.p = d
f.o = e
h.r = f
j.q = f
j.r = f
j.p = m
d.r = e
d.t = c
m.v = e
i.q = j
i.s = h
assert h.r.q.v.q.p.v.q.r.txt == "f"