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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: F = None
        self.s: F = None
        self.t: C = None
        self.v: D = None
        self.r: B = None
        self.w: A = None
        self.txt = txt

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

h = A("h")
e = B("e")
a = C("a")
c = D("c")
i = E("i")
b = F("b")

h.p = b
e.v = i
e.w = a
e.q = h
e.z = h
e.t = c
a.y = h
a.p = e
c.p = a
c.v = i
i.z = b
i.s = b
i.t = a
i.v = c
i.r = e
i.w = h
b.o = a
assert i.r.w.p.z.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: F = None
        self.s: F = None
        self.t: C = None
        self.v: D = None
        self.r: B = None
        self.w: A = None
        self.txt = txt

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

h = A("h")
e = B("e")
a = C("a")
c = D("c")
i = E("i")
b = F("b")

h.p = b
e.v = i
e.w = a
e.q = h
e.z = h
e.t = c
a.y = h
a.p = e
c.p = a
c.v = i
i.z = b
i.s = b
i.t = a
i.v = c
i.r = e
i.w = h
b.o = a
assert i.r.w.p.z.p.o.txt == "a"