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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: F = None
        self.w: G = None
        self.p: F = None
        self.z: A = None
        self.v: C = None
        self.q: 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.q: E = None
        self.o: E = None
        self.t: C = None
        self.w: E = None
        self.v: G = None
        self.txt = txt

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

j = A("j")
h = B("h")
d = C("d")
l = D("l")
n = E("n")
b = F("b")
m = G("m")

j.p = h
h.p = n
d.v = j
d.t = n
l.o = h
l.x = b
l.p = b
l.q = b
l.w = m
l.z = j
l.v = d
n.o = h
b.q = n
b.o = n
b.w = n
b.t = d
b.v = m
m.t = b
m.u = d
m.x = h
assert h.p.o.p.o.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: F = None
        self.w: G = None
        self.p: F = None
        self.z: A = None
        self.v: C = None
        self.q: 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.q: E = None
        self.o: E = None
        self.t: C = None
        self.w: E = None
        self.v: G = None
        self.txt = txt

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

j = A("j")
h = B("h")
d = C("d")
l = D("l")
n = E("n")
b = F("b")
m = G("m")

j.p = h
h.p = n
d.v = j
d.t = n
l.o = h
l.x = b
l.p = b
l.q = b
l.w = m
l.z = j
l.v = d
n.o = h
b.q = n
b.o = n
b.w = n
b.t = d
b.v = m
m.t = b
m.u = d
m.x = h
assert h.p.o.p.o.p.o.txt == "h"