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

class B:
    def __init__(self, txt: str):
        self.r: F = None
        self.s: F = None
        self.x: A = None
        self.q: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: E = None
        self.q: H = None
        self.z: G = None
        self.r: F = None
        self.t: B = None
        self.v: F = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: C = None
        self.w: A = None
        self.v: E = None
        self.txt = txt

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

g.p = f
b.r = i
b.s = i
b.x = g
b.q = f
n.p = a
n.y = g
f.y = b
f.t = b
f.w = a
f.q = d
f.z = k
f.r = i
f.v = i
a.o = b
i.v = a
i.s = k
k.q = a
k.x = d
d.o = n
d.r = n
d.w = g
d.v = a
assert i.v.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: F = None
        self.s: F = None
        self.x: A = None
        self.q: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: E = None
        self.q: H = None
        self.z: G = None
        self.r: F = None
        self.t: B = None
        self.v: F = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: C = None
        self.w: A = None
        self.v: E = None
        self.txt = txt

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

g.p = f
b.r = i
b.s = i
b.x = g
b.q = f
n.p = a
n.y = g
f.y = b
f.t = b
f.w = a
f.q = d
f.z = k
f.r = i
f.v = i
a.o = b
i.v = a
i.s = k
k.q = a
k.x = d
d.o = n
d.r = n
d.w = g
d.v = a
assert i.v.o.r.txt == "i"