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

class B:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: G = None
        self.u: G = None
        self.w: A = None
        self.s: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.o: D = None
        self.t: F = None
        self.v: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.t: B = None
        self.o: C = None
        self.txt = txt

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

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

f.p = g
f.s = k
k.q = c
k.s = c
k.r = d
k.u = d
k.w = f
i.p = f
i.q = a
h.u = f
c.q = f
c.o = h
c.t = a
c.v = k
a.p = g
a.u = g
a.t = k
a.o = i
d.r = k
d.x = c
d.v = i
d.z = a
g.p = f
g.q = a
assert i.q.t.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: G = None
        self.u: G = None
        self.w: A = None
        self.s: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.q: A = None
        self.o: D = None
        self.t: F = None
        self.v: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: C = None
        self.t: B = None
        self.o: C = None
        self.txt = txt

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

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

f.p = g
f.s = k
k.q = c
k.s = c
k.r = d
k.u = d
k.w = f
i.p = f
i.q = a
h.u = f
c.q = f
c.o = h
c.t = a
c.v = k
a.p = g
a.u = g
a.t = k
a.o = i
d.r = k
d.x = c
d.v = i
d.z = a
g.p = f
g.q = a
assert i.q.t.r.r.txt == "k"