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

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

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

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

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

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

b = A("b")
m = B("m")
n = C("n")
a = D("a")
h = E("h")
j = F("j")
k = F("k")
c = A("c")

b.p = a
b.z = h
m.r = c
m.x = h
n.p = h
n.q = h
n.w = m
a.y = c
a.u = m
a.o = n
h.p = m
h.v = j
j.q = b
k.q = b
c.p = a
c.z = h
assert j.q.p.u.x.v.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.z: E = None
        self.txt = txt

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

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

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

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

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

b = A("b")
m = B("m")
n = C("n")
a = D("a")
h = E("h")
j = F("j")
k = F("k")
c = A("c")

b.p = a
b.z = h
m.r = c
m.x = h
n.p = h
n.q = h
n.w = m
a.y = c
a.u = m
a.o = n
h.p = m
h.v = j
j.q = b
k.q = b
c.p = a
c.z = h
assert j.q.p.u.x.v.q.p.txt == "a"