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

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

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

class D:
    def __init__(self, txt: str):
        self.t: F = None
        self.txt = txt

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

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

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

n = A("n")
i = B("i")
k = C("k")
f = D("f")
b = E("b")
c = F("c")
a = G("a")
g = A("g")

n.p = k
i.q = n
i.o = n
k.s = i
k.r = i
f.t = c
b.s = i
c.v = n
c.p = f
c.r = a
a.v = k
a.t = i
a.s = i
g.p = k
assert c.r.t.q.p.r.q.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: F = None
        self.txt = txt

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

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

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

n = A("n")
i = B("i")
k = C("k")
f = D("f")
b = E("b")
c = F("c")
a = G("a")
g = A("g")

n.p = k
i.q = n
i.o = n
k.s = i
k.r = i
f.t = c
b.s = i
c.v = n
c.p = f
c.r = a
a.v = k
a.t = i
a.s = i
g.p = k
assert c.r.t.q.p.r.q.p.r.txt == "i"