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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.s: F = None
        self.q: D = None
        self.z: F = None
        self.o: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.q: C = None
        self.r: D = None
        self.t: E = None
        self.txt = txt

g = A("g")
h = B("h")
i = C("i")
b = D("b")
a = E("a")
k = F("k")

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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.s: F = None
        self.q: D = None
        self.z: F = None
        self.o: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.q: C = None
        self.r: D = None
        self.t: E = None
        self.txt = txt

g = A("g")
h = B("h")
i = C("i")
b = D("b")
a = E("a")
k = F("k")

g.y = k
h.p = g
h.s = k
h.z = k
h.q = b
h.o = i
i.o = k
i.p = k
i.q = h
i.z = h
i.v = g
b.r = h
a.o = i
a.q = k
a.t = k
k.q = i
k.r = b
k.t = a
assert k.r.r.p.y.r.txt == "b"