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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: E = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
g = C("g")
h = D("h")
c = E("c")
d = F("d")

m.y = h
m.u = g
k.t = d
k.s = m
k.x = g
g.y = d
h.o = k
h.s = c
c.t = k
c.r = k
c.o = d
c.v = d
c.p = h
d.w = h
d.p = g
assert d.p.y.p.y.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.s: E = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
g = C("g")
h = D("h")
c = E("c")
d = F("d")

m.y = h
m.u = g
k.t = d
k.s = m
k.x = g
g.y = d
h.o = k
h.s = c
c.t = k
c.r = k
c.o = d
c.v = d
c.p = h
d.w = h
d.p = g
assert d.p.y.p.y.w.o.txt == "k"