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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

a.t = m
j.w = c
j.x = h
g.r = a
g.p = a
g.s = c
g.o = h
g.q = h
c.v = a
c.w = g
c.r = h
c.s = j
c.p = j
n.y = j
m.y = c
m.w = c
m.r = a
h.y = j
assert m.y.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

a.t = m
j.w = c
j.x = h
g.r = a
g.p = a
g.s = c
g.o = h
g.q = h
c.v = a
c.w = g
c.r = h
c.s = j
c.p = j
n.y = j
m.y = c
m.w = c
m.r = a
h.y = j
assert m.y.s.w.txt == "c"