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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.u: D = None
        self.q: A = None
        self.w: E = None
        self.txt = txt

k = A("k")
l = B("l")
f = C("f")
a = D("a")
b = E("b")
c = F("c")
h = E("h")

k.y = f
l.p = h
l.t = c
l.q = f
f.z = c
f.o = a
a.o = c
a.x = f
b.p = h
b.x = k
b.o = l
b.r = l
c.o = f
c.u = a
c.q = k
c.w = b
h.p = b
h.x = k
h.o = l
h.r = l
assert a.o.u.o.o.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.u: D = None
        self.q: A = None
        self.w: E = None
        self.txt = txt

k = A("k")
l = B("l")
f = C("f")
a = D("a")
b = E("b")
c = F("c")
h = E("h")

k.y = f
l.p = h
l.t = c
l.q = f
f.z = c
f.o = a
a.o = c
a.x = f
b.p = h
b.x = k
b.o = l
b.r = l
c.o = f
c.u = a
c.q = k
c.w = b
h.p = b
h.x = k
h.o = l
h.r = l
assert a.o.u.o.o.z.q.txt == "k"